note 78625 added to ref.session

From: Date: Fri, 19 Oct 2007 18:59:35 +0000
Subject: note 78625 added to ref.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-131569@lists.php.net to get a copy of this message
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); } } ---- Server IP: 69.147.83.197 Probable Submitter: 207.245.26.111 ---- Manual Page -- http://www.php.net/manual/en/ref.session.php Edit -- https://master.php.net/note/edit/78625 Del: integrated -- https://master.php.net/note/delete/78625/integrated Del: useless -- https://master.php.net/note/delete/78625/useless Del: bad code -- https://master.php.net/note/delete/78625/bad+code Del: spam -- https://master.php.net/note/delete/78625/spam Del: non-english -- https://master.php.net/note/delete/78625/non-english Del: in docs -- https://master.php.net/note/delete/78625/in+docs Del: other reasons-- https://master.php.net/note/delete/78625 Reject -- https://master.php.net/note/reject/78625 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131569) next »