note 78625 rejected from ref.session by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: mikeh at view22 dot com 

----

Observed what I think is a bug: session cookies were expiring even though the session was still active.  (To test, set a cookie expiry of 5 seconds and keep hitting the page every second.  The session will expire and create a new SESSID after 5 seconds despite the fact that you hit the page only a second ago.)

Calling this function before starting the session fixed it.  It copies the cookie contents back to itself while forcing an update to the expiry time in the cookie.

function FreshenSessionCookie($lifetimeSeconds, $cookieName = 'PHPSESSID') 
{
	if (isset($_COOKIE[$cookieName]))
		{
		$data = $_COOKIE[$cookieName];
		$timeout = time()+$lifetimeSeconds;
		setcookie($cookieName, $data,  $timeout);
		}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.