How to force multiple sessions?
Posted: Thu Jul 30, 2009 10:56 am
I seem to have a fundamental misconception of how sessions work, although I have been coding with them apparently successfully until I found out something today.
At the start of each php script, I have the following:
Today, I wanted to test something on my local server, logging in as two different users. So I logged in with one user, opened a new tab (this is Firefox) and logged in as the other user. I expected to get two different sessions, but the second login used, and overwrote, the existing session file. Can I force separate sessions, or as I said at the start, am I labouring under a fundamental misconception?
(Incidentally, I got exactly the same thing when I ran two separate instances of Firefox.)
At the start of each php script, I have the following:
Code: Select all
session_cache_limiter("nocache");
session_start();
$self = $_SERVER['PHP_SELF']."?".SID;
(Incidentally, I got exactly the same thing when I ran two separate instances of Firefox.)