FF loses $_SESSION data
Hello, I set an session variable in my index.php, say
session_start(); $_SESSION['test']='hello';
I call another skript on the server via AJAX that includes something like:
session_start(); echo ($_SESSION['test']);
This will result in the output of "hello" for some time.
I have a timer running to call the AJAX function every 20secs and sometimes after a few minutes, sometimes after a few hours, FF loses the session variable.
In other words, $_SESSION['test'] is not set anymore. I can echo session_id(); and verify, that the session is still runing, so does the session cookie, but the complete $_SESSION array is lost.
Any ideas?
Regards, Chris.
All Replies (4)
It is my understanding that the browser's role is limited to sending the cookie. If the associated session gets messed up, that sounds like a server/PHP problem...
Do your logs show any unexpected requests for another script that could possibly affect $_SESSION['test']?
Edit: just noticed this post is a week old! This forum focuses on end-user support. You can find more web development help on the mozillaZine Web Development board. Separate forum, separate registration.
Okulungisiwe
Hello jscher2000,
no, it looks like it get's lost out of the blue, but my service provider is working on it.
However, as this only happens with FF, I wasn't sure whether it is a server problem. IE, Safari and even FF under Windwows work just fine. It only happens with FF on my mac machine - could that be related to ADD ONs such as Firebug/FirePHP?
Regards, Chris.
Does any of your code call session_unset() or session_destroy()? Either could clear the variables without invalidating the session itself. Otherwise, I don't see how the session id could remain the same. Admittedly I don't have a lot of experience with PHP.
In case caching is an issue, do you ensure you are bypassing the cache in your AJAX call by adding a parameter such as the current time?
Hi jscher2000,
no, not within the script that is repeatedly called. And the first couple of times it works just fine. Only after I a while the session get's lost.
The current script does not have a parameter like that, but when I tried to find the error I also tried it with an iframe and also with the .src of an image - so not with AJAX, and I used a randam parameter to make sure it is not loaded from cache - still with the same result ...
Regards, Chris.