note 29035 added to function.session-set-save-handler
| From: | Joe at rack1 dot php dot net | Date: | Thu, 30 Jan 2003 23:04:38 +0000 |
| Subject: | note 29035 added to function.session-set-save-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-43163@lists.php.net to get a copy of this message | ||
If you happen to want to build a session manager object you can set the handlers from inside the
class. This helps to keep the class encapsulated which helps make it nice and reusable.
class Session_manager {
...
session_set_save_handler(
array(& $this, 'session_open_method'),
array(& $this, 'session_close_method'),
array(& $this, 'session_read_method'),
array(& $this, 'session_write_method'),
array(& $this, 'session_destroy_method'),
array(& $this, 'session_gc_method')
);
...
}
Each handler is identified by an array containing a self-reference to the instance (note the &)
and a string identifying a method in the session manager class.
Remember that the new operator passes back a copy of the object. This is important if you want to
call session_set_save_handler() from inside the class constructor. You must remember to use another
reference when you create the instance...
$my_session_manager = & new Session_manager;
Otherwise the session handlers will be assigned to an instance which is created by the new operator
and NOT to the copy which is stored in the variable $my_session_manager.
--
http://www.php.net/manual/en/function.session-set-save-handler.php
http://master.php.net/manage/user-notes.php?action=edit+29035
http://master.php.net/manage/user-notes.php?action=delete+29035
http://master.php.net/manage/user-notes.php?action=reject+29035