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