I’ve been searching all over the net and cannot find a solution that actually works, so I’m trying it here...
The problem I have is that I have a page from which I am making an ajax call when the user clicks on a button. Now upon this ajax call some changes are made to some session variables. For some reason I am unable to update/create php session variables using ajax calls.
I’ve checked the session id’s for both the page and the resulting ajax calls and both are the same.
My setup is that I have a document with a snippet in which handles the ajax request, the snippet, for simplicity reasons, currently only has this in it:
if (empty($_SESSION['count']))
$_SESSION['count'] = 1;
$_SESSION['count'] += 1;
return $_SESSION['count'];
On completion of the ajax request the response is just shown on the page. Now one would think, each time I click the button it would show, 1, then 2, 3, 4, etc as I click the button, but it doesn’t, it just keeps on showing 1. I browse directly to the ajax page/resource which I call in the javascript, then it shows, 2, 3, 4, etc. as I refresh, and when I go back to the page with the button and click on the button, it just shows the last number I saw from directly loading the page, in this case 4.
I don’t understand why it does not want to update the session variables when using an ajax call, anybody have ANY idea what is causing this or how to fix it? It’s fairly urgent and I’m getting balder by the minute