Re: session id changing all the time on some pc's

From: Date: Fri, 02 Jul 2004 21:23:10 +0000
Subject: Re: session id changing all the time on some pc's
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.general 
Request: Send a blank email to php-general+get-189585@lists.php.net to get a copy of this message
"Matthew Sims" <matt@killermookie.org> wrote in message news:50795.208.44.135.18.1088800728.squirrel@208.44.135.18... > >> The $_SESSION['sid'] will follow from page to page. As long as the user > stays in the current session, all $_SESSION variables will follow from > page to page as long as session_start() is used. > > > > OK, but HOW do you manage that the user stays in the current session. > Usually this is made sure by passing the session id around. But > obviously > > you are not doing this, are you? > > > > Torsten > > > > As long as the user keeps his browser pointing at your site, then they'll > stay in the currect session. The moment they shut down the web browser, > the session is lost. This does only work *with* using a cookie. > > When the user first comes to your site, assign the session_id to a > $_SESSION variable. Then as the user jumps from page to page, check the > $_SESSION variable with the session_id on that page. > > Try this, on the front page: > > session_start(); > $_SESSOIN['sid']=session_id(); > > On another page: > > if ($_SESSION['sid']==session_id()) { > continue browsing; > } else { > redirect to front page; > } > > or however you want it to be. The above isn't tested. Not sure if > session_id needs to be assigned to a variable. > > Is this what you're referring to or am I just misreading what you're asking? No, this is exactly what I wanted to know. But it would contradict everything I experienced with sessions until now - and it does. I just tested your code (with session_start() also at the top of page2). It does not work because there is absolutely no relation between page1 and page2 with your code. In this case a new session is being started on page two. You have got to pass the session id from one page to another (when not using a cookie) otherwise it won't work and rightly so. Maybe your memory played a trick on you ;) Don't mind. Regards, Torsten

« previous php.general (#189585) next »