Reputation: 1214
I have a somewhat theoretical question this time:
The situation (on a PHP website):
The question:
Would it be possible to update a SESSION array of personal member values with a function, through a file running on the background, called by and updated through jQuery/ajax?
I imagine it would be updating it all in one file, but I wonder if you guys have any thoughts/ideas on this.
Upvotes: 0
Views: 852
Reputation: 4628
The PHP session persists even after scripts are finished running, so you don't need a PHP file running in the background on the server.
Example PHP file (called by the ajax function, assuming the ajax function submits a POST request with the CD's id):
update-favorite.php
$_SESSION['favCDS'][] = $_POST['cd-id'];
That way, when the user navigates to a new page, that page can preserve the favorite CDs by accessing this session array and generating HTML accordingly.
Upvotes: 1