views:

53

answers:

2

Hi,

LAMP test server - only I am visiting it:

I have a website and for some reason I get multiple sessions per user (browser). I am browsing the page with one browser only and I get 5-6-7-8 session files in /tmp. What can be the reason for it?

Sessions are simple file based sessions. I noticed that I get multiple sessions when I update a session variable (current page # is stored in $_SESSION['pagepos']). Updating a session variable for the current user should update the session file and should not create a new session file, right? My session id in the browser remains the same.

Thanks, Hamlet

A: 

If you use flash that requests something from the server (xml/other swf files), then it probably doesn't send any cookies with it and thus - new session is started with each request.

Artjom Kurapov
no flash on the site I removed ajax as well for testing, didn't help
Hamlet
then its either1. some browser plugins2. server proxyTry debugging it by adding some test.php, adding mail() function there that would email you each time script is executed, and then opening this page with clean browser
Artjom Kurapov
A: 

A session being created anew every time would make me think that the session cookie is refused by the browser. Check what cookies you take on board (I use Firecookie, but there are many such extensions for the 'fox).

It happened to me once, and in the end I found I should have left session.cookie_domain commented out in my php.ini

djn
Commented this out, but didn't help. I removed Google adsense, analytics, flash from the page, but it still happens (not every new page, but for approx every second click I get a new session file)
Hamlet
Well, this cuts out any simple explanation. The only thing that comes to my mind might be a very short session timeout.Also, try with a different browser - just to make sure the problem is server-side...If nothing else helps I'd suggest looking directli at the HTTP headers to see when exactly there is a new session (with Fiddler - http://fiddler2.com/fiddler2/version.asp or LiveHTTPHeaders - http://fiddler2.com/fiddler2/version.asp).The last - and most foolproof - idea would be to install XDebug, debug the code stepping thru it one line at a time while keeping a window open ->
djn
-> on the session file folder. Thus you might see exactly at what step a new session file is created
djn
Whoops! The link to LiveHTTPHeaders is https://addons.mozilla.org/en-US/firefox/addon/3829
djn