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--SKIPIF--
8<?php include('skipif.inc'); ?>
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() : using closures as callbacks ***\n";
21
22require_once "save_handler_closures.inc";
23var_dump(session_module_name());
24var_dump(session_module_name(FALSE));
25var_dump(session_module_name("blah"));
26var_dump(session_module_name("foo"));
27
28$path = dirname(__FILE__);
29session_save_path($path);
30session_set_save_handler($open_closure, $close_closure, $read_closure, $write_closure, $destroy_closure, $gc_closure);
31
32session_start();
33$_SESSION["Blah"] = "Hello World!";
34$_SESSION["Foo"] = FALSE;
35$_SESSION["Guff"] = 1234567890;
36var_dump($_SESSION);
37
38session_write_close();
39session_unset();
40var_dump($_SESSION);
41
42echo "Starting session again..!\n";
43session_id($session_id);
44session_set_save_handler($open_closure, $close_closure, $read_closure, $write_closure, $destroy_closure, $gc_closure);
45session_start();
46$_SESSION['Bar'] = 'Foo';
47var_dump($_SESSION);
48session_write_close();
49
50ob_end_flush();
51?>
52--EXPECTF--
53*** Testing session_set_save_handler() : using closures as callbacks ***
54string(%d) "%s"
55
56Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d
57bool(false)
58
59Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d
60bool(false)
61
62Warning: session_module_name(): Cannot find named PHP session module (foo) in %s on line %d
63bool(false)
64Open [%s,PHPSESSID]
65Read [%s,%s]
66array(3) {
67  ["Blah"]=>
68  string(12) "Hello World!"
69  ["Foo"]=>
70  bool(false)
71  ["Guff"]=>
72  int(1234567890)
73}
74Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
75Close [%s,PHPSESSID]
76array(3) {
77  ["Blah"]=>
78  string(12) "Hello World!"
79  ["Foo"]=>
80  bool(false)
81  ["Guff"]=>
82  int(1234567890)
83}
84Starting session again..!
85Open [%s,PHPSESSID]
86Read [%s,%s]
87array(4) {
88  ["Blah"]=>
89  string(12) "Hello World!"
90  ["Foo"]=>
91  bool(false)
92  ["Guff"]=>
93  int(1234567890)
94  ["Bar"]=>
95  string(3) "Foo"
96}
97Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";]
98Close [%s,PHPSESSID]
99