PDA

View Full Version : Random Session Drops


mic2100
09-12-2007, 04:49 PM
Hi,

I have been puzzling over this for a while now and i am not sure what is causing this or how to fix it.

The problem is session variables, they keep get a new session id at random and i am not to sure how i can stop it.

Click here to read a problem i have alread found that is the same as mine. (http://www.webmasterworld.com/forum88/3265.htm)

I have at the top of each page...


ini_set("session.save_path", $_SERVER['DOCUMENT_ROOT']."/ses");
ini_set("session.gc_maxlifetime", "7200");
session_start();


i have even added...


session_id($_COOKIE['PHPSESSID']);


at the top of most pages so it hopfully stays on the same ID but this didn't work. So i am now fresh out of ideas, does anyone know any reason this may be doing this?

Thanks

Inigoesdr
09-12-2007, 05:35 PM
The PHPSESSID should be read by PHP automatically unless you changed the name of the variable in php.ini.

CFMaBiSmAd
09-12-2007, 05:43 PM
If a condition is occurring that php is able to detect, it is likely logging the error to your web server log file. Check the log file and/or turn of full php error reporting to see if there is anything that would point out the cause of the problem.

The link you posted mainly talks about multiple sessions being created that "come back" depending on how the visitor navigates around. That is likely caused by session cookie domain/path problems or even a http vs https protocol difference (cookies are not passed back and forth between http and https protocols.)

If your session is just being dropped after a time period, never to be seen again, then is it like a garbage collection issue.

mic2100
09-12-2007, 06:17 PM
i understand what you mean but i am using a different folder for the session and also altering the lifetime of it so the garbage collection shouldn't apply to this. also the session is still available if you know the session ID it seem to almost just jump to a nice empty one randomly. i am only using it under http and all on the same domain.

i would post code but it happens throughout the whole DB application and that would be to big to post.

the only time any random processes occur is when an ajax request that updates the menu page at random times to show up and coming calls. so this is when i used the PHPSESSID cookie to make sure that it got the right session id but i am not convinced that it is working.

Inigoesdr
09-12-2007, 09:22 PM
so this is when i used the PHPSESSID cookie to make sure that it got the right session id but i am not convinced that it is working.

Right, but it is a cookie to begin with so this code is useless as it's already being done by PHP automatically if the headers are sent, and if not it won't make a difference. The only time the session id might not be sent is if you used something like flash to post data since it doesn't send the browser's HTTP headers.