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 67--EXPECTF-- 68*** Testing session_set_save_handler() : inheritance *** 69array(1) { 70 ["foo"]=> 71 string(5) "hello" 72} 73int(4) 74string(%d) "%s" 75array(2) { 76 ["foo"]=> 77 string(5) "hello" 78 ["bar"]=> 79 string(5) "hello" 80} 81string(3) "hai" 82