note 104847 added to function.session-set-save-handler
| From: | pavelc at users dot sourceforge dot net | Date: | Mon, 11 Jul 2011 11:21:43 +0000 |
| Subject: | note 104847 added to function.session-set-save-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181416@lists.php.net to get a copy of this message | ||
I write a class that unites whole handler functionality. It's not even needed to save instances
of this class in variables. Just add a row:
<?php
new SessionSaveHandler();
?>
and the handler will rule the sessions ;-)
<?php
class SessionSaveHandler {
protected $savePath;
protected $sessionName;
public function __construct() {
session_set_save_handler(
array($this, "open"),
array($this, "close"),
array($this, "read"),
array($this, "write"),
array($this, "destroy"),
array($this, "gc")
);
}
public function open($savePath, $sessionName) {
$this->savePath = $savePath;
$this->sessionName = $sessionName;
return true;
}
public function close() {
// your code if any
return true;
}
public function read($id) {
// your code
}
public function write($id, $data) {
// your code
}
public function destroy($id) {
// your code
}
public function gc($maxlifetime) {
// your code
}
}
new SessionSaveHandler();
?>
----
Server IP: 69.147.83.197
Probable Submitter: 95.87.248.226
----
Manual Page -- http://www.php.net/manual/en/function.session-set-save-handler.php
Edit -- https://master.php.net/note/edit/104847
Del: integrated -- https://master.php.net/note/delete/104847/integrated
Del: useless -- https://master.php.net/note/delete/104847/useless
Del: bad code -- https://master.php.net/note/delete/104847/bad+code
Del: spam -- https://master.php.net/note/delete/104847/spam
Del: non-english -- https://master.php.net/note/delete/104847/non-english
Del: in docs -- https://master.php.net/note/delete/104847/in+docs
Del: other reasons-- https://master.php.net/note/delete/104847
Reject -- https://master.php.net/note/reject/104847
Search -- https://master.php.net/manage/user-notes.php