HTTP_Session fix and enhancement

From: Date: Wed, 22 Oct 2003 12:38:56 +0000
Subject: HTTP_Session fix and enhancement
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-22904@lists.php.net to get a copy of this message
Hello, I made three changes to the HTTP/Session.php file: 1. Added updateExpire() method like updateIdle(), I use as followes: - after idle time a new login has do be performed but session values will stay - expiration for me means time after last successfully send login 2. Added getExpire() method used to detect expiration before it occures it returns the time in seconds till the expiration 3. Fixed TODO Save expire and idle timestamps I implemented and tested everything locally and made a diff for you. Maybe you can integrate it in the next version of HTTP_Session. Best regards Alexander Diff of HTTP/Session.php ===================== 203a204 > * @todo TODO Save expire and idle timestamps? 210,218c211,213 < $keep = array(); < foreach(array('__HTTP_Session_Info', < '__HTTP_Session_Idle_TS', < '__HTTP_Session_Expire_TS') as $name) < if (isset($_SESSION[$name])) < $keep[$name] = $_SESSION[$name]; < session_unset(); < foreach($keep as $name => $value) < $_SESSION[$name] = $value; --- > $info = $_SESSION['__HTTP_Session_Info']; > session_unset(); > $_SESSION['__HTTP_Session_Info'] = $info; 352,365d346 < /** < * Calculate the time till expiration < * < * @static < * @access public < * @return int time in seconds till expiration < */ < function getExpire() < { < if ($GLOBALS['__HTTP_Session_Expire'] == 0 || !isset($_SESSION['__HTTP_Session_Expire_TS'])) < return 999999999; < return $_SESSION['__HTTP_Session_Expire_TS'] + $GLOBALS['__HTTP_Session_Expire'] - time(); < } < 396,410c377 < < /** < * Updates the expire time < * < * @static < * @access public < * @return void < */ < function updateExpire() < { < if (isset($_SESSION['__HTTP_Session_Expire_TS'])) { < $_SESSION['__HTTP_Session_Expire_TS'] = time(); < } < } <

« previous php.pear.dev (#22904) next »