note 8901 added to Session handling functions

From: Date: Thu, 05 Oct 2000 02:07:16 +0000
Subject: note 8901 added to Session handling functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-6103@lists.php.net to get a copy of this message
To counter the problem of sessions living beyond the session.gc_maxlife setting (it still does in PHP4.0.2 due to the fact that gc only happens AFTER the session is validated, see note by shanemayer42@yahoo.com), you can modify sequence via session_set_save_handler to do gc BEFORE any session is even loaded. It is especially relevant if you are using a db for the session mgmt. function open ($save_path, $sess_name) { // open db connection; gc(get_cfg_var"session.gc_maxlifetime")); } ... // the other functions (read, write etc) ... function gc ($max_lifetime) { // cleanup code } session_set_save_handler ("open", "close","read","write","destroy","gc"); It's quick and dirty, ok, maybe not so quick, but it works! For non db, it's like rewriting the whole code. And for those wishing to try out session mgmt using object, it does not seem to work at all. Any clarifications from zend?? http://www.php.net/manual/ref.session.php

« previous php.notes (#6103) next »