note 20666 deleted from function.session-set-save-handler by sniper
| From: | sniper@php.net | Date: | Wed, 09 Jul 2003 15:54:24 +0000 |
| Subject: | note 20666 deleted from function.session-set-save-handler by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-51798@lists.php.net to get a copy of this message | ||
Note Submitter: pete@mdsc.com
----
Undocumented is the fact that you can use object methods as your session save handlers. This works
with PHP 4.1.2 - I'm not sure which previous versions work.
If you have a class Session with methods _open, _close, _read, _write, _destroy, and _gc, then
something like this will work:
$GLOBALS['SESSION_OBJ'] = new Session($params);
session_set_save_handler(
Array(&$GLOBALS['SESSION_OBJ'], '_open'),
Array(&$GLOBALS['SESSION_OBJ'], '_close'),
Array(&$GLOBALS['SESSION_OBJ'], '_read'),
Array(&$GLOBALS['SESSION_OBJ'], '_write'),
Array(&$GLOBALS['SESSION_OBJ'], '_destroy'),
Array(&$GLOBALS['SESSION_OBJ'], '_gc'));
Make sure to pass the object by reference (with &)