I have a strange problem which is occurring with AJAX. I run a PHP page which I pass it some variables using AJAX which works fine. The problem I have is $_SESSION does not work. I start the session the same way very page which works fine although for some reason when using AJAX to run a page, $_SESSION does not work.
The code works fine on all browsers (FF, IE, Safari, Opera etc) although the error does not occur often. When it occurred the browser was IE although I do believe the browser is one which has been optimised/adapted.
Any help would be most gratefully appreciated as I cannot even create the error myself.
I hit an issue where suhosin was using the user agent to encrypt the session. In IE8 if you have compatibility mode on, the UA for the page is IE7 but for the request is IE8 the solution was to turn off suhosin.session.cryptua
I would do some logging to see if the session cookie is being sent. I assume $_SESSION "doesnt work" means that the $_SESSION array is empty, when there should be data in it? Or is the problem that adding new data doesn't get saved?
There's also a possible race condition. Normally, using the default files save handler, php will manage concurrency and only allow a single script access to a given session at a time. There's some things that can make it not work right.
Since you know the user agent string of this special IE, I would look at your access logs to see if you see anything odd, paying careful attention to the timestamps of each request. You might do some of your own logging to supplement it if needed.
$_SESSION has values already set so all I am trying to get is those values. I start the session as normal but for some reason some customers $_SESSION is empty I guess the session has not started. The main page has started the session then AJAX is used to run a different PHP page which starts the session and uses $_SESSION although this is the page were the problem exists as $_SESSION is empty.
I have checked all the logs and there is nothing relating to this error.
Is it possible for the session to be locked on one browser and not another as the problem does not exist on all other browsers?
I cannot replicate the error so its difficult to find a solution at present.
If the session is locked what solution do I have, is it possible for me to unlock the session before using AJAX?
Bookmarks