note 20666 added to function.session-set-save-handler
| From: | pete at mdsc dot com | Date: | Thu, 11 Apr 2002 21:41:36 +0000 |
| Subject: | note 20666 added to function.session-set-save-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29128@lists.php.net to get a copy of this message | ||
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 &)
--
http://www.php.net/manual/en/function.session-set-save-handler.php
http://master.php.net/manage/user-notes.php?action=edit+20666
http://master.php.net/manage/user-notes.php?action=delete+20666
http://master.php.net/manage/user-notes.php?action=reject+20666