1--TEST-- 2Test session_set_save_handler() function : variation 3--SKIPIF-- 4<?php include('skipif.inc'); ?> 5--INI-- 6session.gc_probability=1 7session.gc_divisor=1 8session.gc_maxlifetime=0 9session.save_path= 10session.name=PHPSESSID 11--FILE-- 12<?php 13 14ob_start(); 15 16/* 17 * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) 18 * Description : Sets user-level session storage functions 19 * Source code : ext/session/session.c 20 */ 21 22echo "*** Testing session_set_save_handler() : variation ***\n"; 23 24function noisy_gc($maxlifetime) { 25 echo("GC [".$maxlifetime."]\n"); 26 gc($maxlifetime); 27} 28 29require_once "save_handler.inc"; 30$path = dirname(__FILE__); 31session_save_path($path); 32session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc"); 33 34session_start(); 35$_SESSION["Blah"] = "Hello World!"; 36$_SESSION["Foo"] = FALSE; 37$_SESSION["Guff"] = 1234567890; 38var_dump($_SESSION); 39$session_id = session_id(); 40var_dump(session_write_close()); 41 42session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc"); 43session_id($session_id); 44session_start(); 45var_dump($_SESSION); 46var_dump(session_destroy()); 47 48ob_end_flush(); 49?> 50--EXPECTF-- 51*** Testing session_set_save_handler() : variation *** 52 53Open [%s,PHPSESSID] 54Read [%s,%s] 55GC [0] 56array(3) { 57 ["Blah"]=> 58 string(12) "Hello World!" 59 ["Foo"]=> 60 bool(false) 61 ["Guff"]=> 62 int(1234567890) 63} 64Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] 65Close [%s,PHPSESSID] 66NULL 67Open [%s,PHPSESSID] 68Read [%s,%s] 69GC [0] 70array(3) { 71 ["Blah"]=> 72 string(12) "Hello World!" 73 ["Foo"]=> 74 bool(false) 75 ["Guff"]=> 76 int(1234567890) 77} 78Destroy [%s,%s] 79 80Warning: unlink(%s): No such file or directory in %s on line %d 81Close [%s,PHPSESSID] 82bool(true) 83 84