1--TEST-- 2Test session_set_save_handler() function : test write short circuit 3--INI-- 4session.save_path= 5session.name=PHPSESSID 6--SKIPIF-- 7<?php include('skipif.inc'); ?> 8skip - Waiting RFC patch merge 9--FILE-- 10<?php 11 12ob_start(); 13 14/* 15 * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) 16 * Description : Sets user-level session storage functions 17 * Source code : ext/session/session.c 18 */ 19 20echo "*** Testing session_set_save_handler() : test write short circuit ***\n"; 21 22require_once "save_handler.inc"; 23$path = dirname(__FILE__); 24session_save_path($path); 25session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); 26 27session_start(); 28$session_id = session_id(); 29$_SESSION["Blah"] = "Hello World!"; 30$_SESSION["Foo"] = FALSE; 31$_SESSION["Guff"] = 1234567890; 32var_dump($_SESSION); 33 34session_write_close(); 35session_unset(); 36var_dump($_SESSION); 37 38echo "Starting session again..!\n"; 39session_id($session_id); 40session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); 41session_start(); 42var_dump($_SESSION); 43$_SESSION['Bar'] = 'Foo'; 44session_write_close(); 45 46echo "Starting session again..!\n"; 47session_id($session_id); 48session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); 49session_start(); 50var_dump($_SESSION); 51// $_SESSION should be the same and should skip write() 52session_write_close(); 53 54ob_end_flush(); 55?> 56--EXPECTF-- 57*** Testing session_set_save_handler() : test write short circuit *** 58 59Open [%s,PHPSESSID] 60Read [%s,%s] 61array(3) { 62 ["Blah"]=> 63 string(12) "Hello World!" 64 ["Foo"]=> 65 bool(false) 66 ["Guff"]=> 67 int(1234567890) 68} 69Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] 70Close [%s,PHPSESSID] 71array(3) { 72 ["Blah"]=> 73 string(12) "Hello World!" 74 ["Foo"]=> 75 bool(false) 76 ["Guff"]=> 77 int(1234567890) 78} 79Starting session again..! 80Open [%s,PHPSESSID] 81Read [%s,%s] 82array(3) { 83 ["Blah"]=> 84 string(12) "Hello World!" 85 ["Foo"]=> 86 bool(false) 87 ["Guff"]=> 88 int(1234567890) 89} 90Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";] 91Close [%s,PHPSESSID] 92Starting session again..! 93Open [%s,PHPSESSID] 94Read [%s,%s] 95array(4) { 96 ["Blah"]=> 97 string(12) "Hello World!" 98 ["Foo"]=> 99 bool(false) 100 ["Guff"]=> 101 int(1234567890) 102 ["Bar"]=> 103 string(3) "Foo" 104} 105Close [%s,PHPSESSID]