session

From: Date: Wed, 17 Aug 2005 00:48:34 +0000
Subject: session
Groups: php.db 
Request: Send a blank email to php-db+get-40087@lists.php.net to get a copy of this message
In my php.ini I've enabled session.use_cookies=1 Everytime I initialize a session, it create the session storage file in my /tmp At the top my script, I've added session_start (); In my test login function, this was what I did: $_SESSION['username'] = 'abcdef'; session_set_cookie_params (time () + 3600); Whereas, in my logout function: unset ($_SESSION['username']); setcookie ('PHPSESSID', '', time () -1); Everytime I load this page, this is what it does: echo "<p>{$_SESSION['username']}"; Everytime load this page a session id is generated, which means, a session file name sess_<current session_id> is created, and my session variable $_SESSION['username'] get stored in there. Now, everytime I perform a logout, it creates a sess_<session id> file under /tmp, and when I perform a login again, it creates yet another sess_<session id>. I'm not exactly sure why does it do this. My intention is actually, to use register a session variable to denote login status, and session_set_cookie_params (); to set the expiry date for the cookie for my session. And every the page loads, to use session_get_cookie_params (); to check whether the cookie has expired, if it has, force for a new login (via redirect or link), if it hasn't expired, display the appropriate "authenticated" page content. Thanks.

« previous php.db (#40087) next »