session

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux