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