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 ***
54
55string(%d) "%s"
56
57Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d
58bool(false)
59
60Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d
61bool(false)
62
63Warning: session_module_name(): Cannot find named PHP session module (foo) in %s on line %d
64bool(false)
65Open [%s,PHPSESSID]
66Read [%s,%s]
67array(3) {
68  ["Blah"]=>
69  string(12) "Hello World!"
70  ["Foo"]=>
71  bool(false)
72  ["Guff"]=>
73  int(1234567890)
74}
75Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
76Close [%s,PHPSESSID]
77array(3) {
78  ["Blah"]=>
79  string(12) "Hello World!"
80  ["Foo"]=>
81  bool(false)
82  ["Guff"]=>
83  int(1234567890)
84}
85Starting session again..!
86Open [%s,PHPSESSID]
87Read [%s,%s]
88array(4) {
89  ["Blah"]=>
90  string(12) "Hello World!"
91  ["Foo"]=>
92  bool(false)
93  ["Guff"]=>
94  int(1234567890)
95  ["Bar"]=>
96  string(3) "Foo"
97}
98Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";]
99Close [%s,PHPSESSID]
100