1--TEST-- 2Test session_set_save_handler() : basic class wrapping existing handler 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() : basic class wrapping existing handler ***\n"; 20 21class MySession extends SessionHandler { 22 public $i = 0; 23 public function open($path, $name) { 24 ++$this->i; 25 echo 'Open ', session_id(), "\n"; 26 return parent::open($path, $name); 27 } 28 public function read($key) { 29 ++$this->i; 30 echo 'Read ', session_id(), "\n"; 31 return parent::read($key); 32 } 33} 34 35$oldHandler = ini_get('session.save_handler'); 36$handler = new MySession; 37session_set_save_handler($handler); 38session_start(); 39 40var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); 41 42$_SESSION['foo'] = "hello"; 43 44session_write_close(); 45session_unset(); 46 47session_start(); 48var_dump($_SESSION); 49 50session_write_close(); 51session_unset(); 52 53--EXPECTF-- 54*** Testing session_set_save_handler() : basic class wrapping existing handler *** 55Open 56Read %s 57string(%d) "%s" 58string(5) "files" 59string(4) "user" 60int(2) 61array(0) { 62} 63Open %s 64Read %s 65array(1) { 66 ["foo"]=> 67 string(5) "hello" 68} 69