Table of Contents

Object oriented session handlers

Introduction

This patch allows users to extend session handlers in an object oriented fashion.

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, and alters session_set_save_handler() to also accept an object of this class.

Example uses of overriding/wrapping individual methods of a handler:

Example

<?php
class MySession extends SessionHandler {
	public function read($key) {
		return str_rot13(parent::read($key));
	}
 
	public function write($key, $data) {
		return parent::write($key, str_rot13($data));
	}
}
 
session_set_save_handler(new MySession);
 
?>

Usage notes

Patches

http://spellign.com/patches/php-trunk-session-oo12.patch

http://spellign.com/patches/php-5.4-session-oo12.patch

http://spellign.com/patches/php-trunk-session-oo12-tests.patch

Changelog