rfc:session-oo
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:session-oo [2011/06/03 01:00] – slightly more useful example arpad | rfc:session-oo [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Object oriented session handlers | ====== Object oriented session handlers | ||
- | * Version: 1.0 | + | * Version: 1.1 |
- | * Date: 2011-06-03 | + | * Date: 2011-06-20 |
* Author: Arpad Ray < | * Author: Arpad Ray < | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
* Original discussion: http:// | * Original discussion: http:// | ||
+ | * Current discussion: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
Line 13: | Line 14: | ||
Currently users must override all six functions and have no way of calling the original ones. | Currently users must override all six functions and have no way of calling the original ones. | ||
- | This patch exposes the original handler (files, memcached, etc.) in a new internal class called SessionHandler, | + | This patch exposes the original handler (files, memcached, etc.) in a new internal class called SessionHandler, |
Example uses of overriding/ | Example uses of overriding/ | ||
Line 25: | Line 26: | ||
<?php | <?php | ||
class MySession extends SessionHandler { | class MySession extends SessionHandler { | ||
- | public | + | public function read($key) { |
return str_rot13(parent:: | return str_rot13(parent:: | ||
} | } | ||
- | public | + | public function write($key, $data) { |
return parent:: | return parent:: | ||
} | } | ||
} | } | ||
- | session_set_save_handler('MySession'); | + | session_set_save_handler(new MySession); |
?> | ?> | ||
Line 41: | Line 42: | ||
===== Usage notes ===== | ===== Usage notes ===== | ||
- | * Calling session_set_save_handler(class) after session_set_save_handler(a, | + | * Calling session_set_save_handler(object) after session_set_save_handler(a, |
- | * Likewise multiple session_set_save_handler(class) calls simply replace each other; just extend the new class from the old one instead of SessionHandler to chain them. | + | * Likewise multiple session_set_save_handler(object) calls simply replace each other; just extend the new class from the old one instead of SessionHandler to chain them. |
* An E_WARNING error is raised if the (parent) SessionHandler class is used (read/ | * An E_WARNING error is raised if the (parent) SessionHandler class is used (read/ | ||
- | * Calling session_set_save_handler(object) merely gets the class from the object and proceeds as if session_set_save_handler(class) were called. | ||
- | ===== Patch ===== | + | ===== Patches |
- | The patch is available at http:// | + | http:// |
+ | |||
+ | http:// | ||
+ | |||
+ | http:// | ||
===== Changelog ===== | ===== Changelog ===== | ||
- | 2011-06-03 Arpad Ray: Initial RFC creation | + | * 2011-06-03 Arpad Ray: Initial RFC creation |
+ | * 2011-06-20 Arpad Ray: Updated to reflect new patches | ||
+ | * 2011-06-20 Arpad Ray: Updated patches | ||
+ | * 2011-06-27 Arpad Ray: Updated patches | ||
rfc/session-oo.1307062828.txt.gz · Last modified: 2017/09/22 13:28 (external edit)