Re: session

From: Date: Wed, 17 Aug 2005 00:52:48 +0000
Subject: Re: session
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-40088@lists.php.net to get a copy of this message
And I've forgot to mention the fact that my session_set_cookie_params (); even if I've supplies a url and a domain, e.g. $_SESSION['username'] = 'abc123'; session_set_cookie_params (time () + 3600, "/myurl/", ".mydomain.com"); And with session_get_cookie_params (); I don't even get any values as for for lifetime, url and host. Regards and thank again. Shahmat Dahlan wrote:
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 (#40088) next »