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