rfc:session-oo
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:session-oo [2011/06/03 00:44] – created arpad | rfc:session-oo [2011/08/27 18:20] – [Patches] arpad | ||
---|---|---|---|
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 22: | Line 23: | ||
===== Example ===== | ===== Example ===== | ||
- | < | + | < |
<?php | <?php | ||
class MySession extends SessionHandler { | class MySession extends SessionHandler { | ||
- | public | + | public function |
- | echo 'Open ', session_id(), " | + | return str_rot13(parent::read($key)); |
- | return | + | |
} | } | ||
- | public | + | |
- | echo 'Read ', session_id(), | + | public function |
- | return parent::read($key); | + | return parent::write($key, str_rot13($data)); |
} | } | ||
} | } | ||
- | session_set_save_handler('MySession'); | + | session_set_save_handler(new MySession); |
?> | ?> | ||
Line 42: | 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.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1