AjBaz100 Posted August 31, 2008 Share Posted August 31, 2008 I have the strangest problem with sessions. On Friday when I left work, everything was working fine, but this morning when I came in I noticed that none of my sessions are working. I'm using Ajax to call a php script and return a value that is based on a session state. I've broken down the script to a very simple session and still no luck. Here is an example. Javascript var myRequest = new ajaxObject( '/displays/eb/overlayContent.php' ); myRequest.update( params, 'GET' ); myRequest.callback = function(responseText) { if( responseText.length ) { alert( responseText ); } } PHP <?php session_start(); echo " --".$_SESSION['Test']."-- "; $_SESSION['Test'] = "Hello"; ?> On the first call, ---- is returned, which is correct, but I would have thought that on the second call to this page --Hello-- should be returned. I've checked the /var/lib/php5 directory and session files are being written, but it seams to write a file for every page request. So it's like it's creating a new session for every request. I've also skipped the ajax call and gone directly to the URL, still a new session file is being created for each page request, and the session isn't holding the value. What is strange though is that this was working fine on Friday. I've never had this kind of problem with PHP before, and I'm a little stumped on a solution. Link to comment https://forums.phpfreaks.com/topic/122144-php-sessions/ Share on other sites More sharing options...
GingerRobot Posted August 31, 2008 Share Posted August 31, 2008 Sounds like the session ID is not being retained. Have you disabled cookies? Unless you pass the session ID around in the URL and with hidden forms, a cookie is needed to keep track of the session ID. Have you tried using a different browser? Link to comment https://forums.phpfreaks.com/topic/122144-php-sessions/#findComment-630604 Share on other sites More sharing options...
AjBaz100 Posted August 31, 2008 Author Share Posted August 31, 2008 Yes, I've tried using firefox 3 and IE 7, and I've also tried it from a couple of different computers. I've put the exact same code on a different server and it worked fine. So this lead me to think that something had gone wrong with the php.ini file, So i copied the php.ini file from the server that worked on the the one that doesn't, restarted apache and still same problem. Link to comment https://forums.phpfreaks.com/topic/122144-php-sessions/#findComment-630630 Share on other sites More sharing options...
AjBaz100 Posted August 31, 2008 Author Share Posted August 31, 2008 you are also spot on in that the session id isn't being retained. This is the output from session_id(); 937a57f8dcd4935a29fe54f534fa6307 - request 1 5843c3c6bb8d36fb8ebbd2ddf23a0329 - request 2. I've checked the disk usage on the box, file system looks ok, no I/O errors and php.ini file settings look ok. Link to comment https://forums.phpfreaks.com/topic/122144-php-sessions/#findComment-630635 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.