note 58609 added to function.session-set-save-handler

From: Date: Wed, 09 Nov 2005 14:48:44 +0000
Subject: note 58609 added to function.session-set-save-handler
Groups: php.notes 
Request: Send a blank email to php-notes+get-98332@lists.php.net to get a copy of this message
REPLY TO >>>>> Keamos at gmail dot com [ 23-Oct-2005 10:34 ] I would like to mention that there is a major flaw in your implementation: I'll explain: look at the 1st line: $sessionLifetime = get_cfg_var("session.gc_maxlifetime"); then look at the write function in short: global $db, $sessionLifetime; $expiry = time() + $sessionLifetime; $sql = 'SELECT expiry FROM ' . SESSIONS_TABLE . " WHERE sessionid=$sessionid"; if(null === $sql) { $sql = 'INSERT INTO ' . SESSIONS_TABLE . " (sessionid, expiry, value) VALUES ($sessionid, $expiry, $sessionData)"; } else { $sql = 'UPDATE ' . SESSIONS_TABLE . " SET expiry=$expiry, value=$sessionData WHERE sessionid=$sessionid"; } then look at the garbage function in short: $sql = 'DELETE FROM ' . SESSIONS_TABLE . " WHERE expiry < $time"; if you look carefully you will see this in the write function: $expiry = time() + $sessionLifetime; and this in the garbage function: 'DELETE FROM ' . SESSIONS_TABLE . " WHERE expiry < $time"; to be short, your session will never be destroyed except when you explicitly call the destroy function! have a nice 1... ---- Manual Page -- http://www.php.net/manual/en/function.session-set-save-handler.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58609 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58609&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58609&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58609&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58609&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58609&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58609&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58609&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58609&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98332) next »