note 8901 deleted from ref.session by yohgaki

From: Date: Sat, 19 Jan 2002 06:25:12 +0000
Subject: note 8901 deleted from ref.session by yohgaki
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25094@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??

« previous php.notes (#25094) next »