It may seem like it works, but it does what you need. Serialization is applied when your custom session handler receives $_SESSION superglobal, and you need to return it from the read handler as serialized. But you can store the session like any serialization or format or whatever.
Example
class SessionHandler { 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) { return true; } public function close() { return true; } public function read($id) { $data = CustomStorage::fetchSessionData($id); return serialize( CustomSerialization::unserialize($data); ); } public function write($id, $serializedData) { CustomStorage::writeSessionData( $id ,CustomSerialization::serialize(unserialize($serializedData)) ); return true; }
Although this is not very pretty and with little overhead, you only need to control the serialization during storage, so it should do the trick.
Hope this helps!
capi
source share