1--TEST-- 2Test session_set_save_handler() function : using closures as callbacks 3--INI-- 4session.save_path= 5session.name=PHPSESSID 6session.save_handler=files 7--EXTENSIONS-- 8session 9--FILE-- 10<?php 11 12ob_start(); 13 14echo "*** Testing session_set_save_handler() : using closures as callbacks ***\n"; 15 16require_once "save_handler_closures.inc"; 17var_dump(session_module_name()); 18var_dump(session_module_name(FALSE)); 19var_dump(session_module_name("blah")); 20var_dump(session_module_name("foo")); 21 22$path = __DIR__ . '/session_set_save_handler_closures'; 23@mkdir($path); 24session_save_path($path); 25session_set_save_handler($open_closure, $close_closure, $read_closure, $write_closure, $destroy_closure, $gc_closure); 26 27session_start(); 28$_SESSION["Blah"] = "Hello World!"; 29$_SESSION["Foo"] = FALSE; 30$_SESSION["Guff"] = 1234567890; 31var_dump($_SESSION); 32 33session_write_close(); 34session_unset(); 35var_dump($_SESSION); 36 37echo "Starting session again..!\n"; 38session_id($session_id); 39session_set_save_handler($open_closure, $close_closure, $read_closure, $write_closure, $destroy_closure, $gc_closure); 40session_start(); 41$_SESSION['Bar'] = 'Foo'; 42var_dump($_SESSION); 43session_write_close(); 44 45echo "Cleanup\n"; 46session_start(); 47session_destroy(); 48 49ob_end_flush(); 50@rmdir($path); 51?> 52--EXPECTF-- 53*** Testing session_set_save_handler() : using closures as callbacks *** 54string(%d) "%s" 55 56Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d 57bool(false) 58 59Warning: session_module_name(): Session handler module "blah" cannot be found in %s on line %d 60bool(false) 61 62Warning: session_module_name(): Session handler module "foo" cannot be found in %s on line %d 63bool(false) 64 65Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d 66Open [%s,PHPSESSID] 67Read [%s,%s] 68array(3) { 69 ["Blah"]=> 70 string(12) "Hello World!" 71 ["Foo"]=> 72 bool(false) 73 ["Guff"]=> 74 int(1234567890) 75} 76Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] 77Close [%s,PHPSESSID] 78array(3) { 79 ["Blah"]=> 80 string(12) "Hello World!" 81 ["Foo"]=> 82 bool(false) 83 ["Guff"]=> 84 int(1234567890) 85} 86Starting session again..! 87 88Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d 89Open [%s,PHPSESSID] 90Read [%s,%s] 91array(4) { 92 ["Blah"]=> 93 string(12) "Hello World!" 94 ["Foo"]=> 95 bool(false) 96 ["Guff"]=> 97 int(1234567890) 98 ["Bar"]=> 99 string(3) "Foo" 100} 101Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";] 102Close [%s,PHPSESSID] 103Cleanup 104Open [%s,PHPSESSID] 105Read [%s,%s] 106Destroy [%s,%s] 107Close [%s,PHPSESSID] 108