1--TEST-- 2Test session_set_save_handler() : inheritance 3--INI-- 4session.save_handler=files 5session.name=PHPSESSID 6--SKIPIF-- 7<?php include('skipif.inc'); ?> 8--FILE-- 9<?php 10 11ob_start(); 12 13/* 14 * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) 15 * Description : Sets user-level session storage functions 16 * Source code : ext/session/session.c 17 */ 18 19echo "*** Testing session_set_save_handler() : inheritance ***\n"; 20 21class MySession3 extends SessionHandler { 22 public $i = 0; 23 public function open($path, $name) { 24 ++$this->i; 25 return parent::open($path, $name); 26 } 27 public function read($key) { 28 ++$this->i; 29 return parent::read($key); 30 } 31} 32 33class MySession4 extends MySession3 { 34 public function write($id, $data) { 35 $this->i = "hai"; 36 return parent::write($id, $data); 37 } 38} 39 40$handler = new MySession3; 41session_set_save_handler($handler); 42session_start(); 43 44$_SESSION['foo'] = "hello"; 45 46session_write_close(); 47session_unset(); 48 49session_start(); 50 51var_dump($_SESSION, $handler->i); 52 53session_write_close(); 54session_unset(); 55 56$handler = new MySession4; 57session_set_save_handler($handler); 58 59session_start(); 60 61$_SESSION['bar'] = 'hello'; 62session_write_close(); 63session_unset(); 64 65var_dump(session_id(), $_SESSION, $handler->i); 66--EXPECTF-- 67*** Testing session_set_save_handler() : inheritance *** 68array(1) { 69 ["foo"]=> 70 string(5) "hello" 71} 72int(4) 73string(%d) "%s" 74array(2) { 75 ["foo"]=> 76 string(5) "hello" 77 ["bar"]=> 78 string(5) "hello" 79} 80string(3) "hai" 81