note 100674 added to function.session-set-cookie-params

From: Date: Fri, 29 Oct 2010 10:17:49 +0000
Subject: note 100674 added to function.session-set-cookie-params
Groups: php.notes 
Request: Send a blank email to php-notes+get-173592@lists.php.net to get a copy of this message
@ final dot wharf at gmail dot com You are changing the lifetime of the session cookie but not of the session. It may be still valid, even if the session cookie expires. In order to change the lifetime of the session you could use session.gc_maxlifetime. By default, the gargabe collector isn't started on every page refresh. So there is one option left to handle the session lifetime: create your own session lifetime management. For example, initialize the session with the following vars <?php $_SESSION['start'] = time(); $_SESSION['end'] = time() + 1800; ?> Then you create a simple routine, which you call at the beginning of your site, to extend the session lifetime or to end the session: <?php if ($_SESSION['end'] < time()) { session_unset(); session_destroy(); return; } if (($_SESSION['end'] - time()) > 0) { return $_SESSION['end'] = time() + 1800; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 84.155.63.52 ---- Manual Page -- http://www.php.net/manual/en/function.session-set-cookie-params.php Edit -- https://master.php.net/note/edit/100674 Del: integrated -- https://master.php.net/note/delete/100674/integrated Del: useless -- https://master.php.net/note/delete/100674/useless Del: bad code -- https://master.php.net/note/delete/100674/bad+code Del: spam -- https://master.php.net/note/delete/100674/spam Del: non-english -- https://master.php.net/note/delete/100674/non-english Del: in docs -- https://master.php.net/note/delete/100674/in+docs Del: other reasons-- https://master.php.net/note/delete/100674 Reject -- https://master.php.net/note/reject/100674 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173592) next »