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
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__;
24session_save_path($path);
25session_set_save_handler("open", "close", "read", "write", "destroy", "gc");
26
27session_start();
28$session_id = session_id();
29$_SESSION["Blah"] = "Hello World!";
30$_SESSION["Foo"] = FALSE;
31$_SESSION["Guff"] = 1234567890;
32var_dump($_SESSION);
33
34session_write_close();
35session_unset();
36var_dump($_SESSION);
37
38echo "Starting session again..!\n";
39session_id($session_id);
40session_set_save_handler("open", "close", "read", "write", "destroy", "gc");
41session_start();
42var_dump($_SESSION);
43$_SESSION['Bar'] = 'Foo';
44session_write_close();
45
46echo "Garbage collection..\n";
47session_id($session_id);
48session_start();
49var_dump(session_gc());
50session_write_close();
51
52echo "Cleanup..\n";
53session_id($session_id);
54session_start();
55session_destroy();
56
57ob_end_flush();
58?>
59--EXPECTF--
60*** Testing session_set_save_handler() : basic functionality ***
61string(%d) "%s"
62
63Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
64bool(false)
65
66Warning: session_module_name(): Session handler module "blah" cannot be found in %s on line %d
67bool(false)
68
69Warning: session_module_name(): Session handler module "foo" cannot be found in %s on line %d
70bool(false)
71Open [%s,PHPSESSID]
72Read [%s,%s]
73array(3) {
74  ["Blah"]=>
75  string(12) "Hello World!"
76  ["Foo"]=>
77  bool(false)
78  ["Guff"]=>
79  int(1234567890)
80}
81Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
82Close [%s,PHPSESSID]
83array(3) {
84  ["Blah"]=>
85  string(12) "Hello World!"
86  ["Foo"]=>
87  bool(false)
88  ["Guff"]=>
89  int(1234567890)
90}
91Starting session again..!
92Open [%s,PHPSESSID]
93Read [%s,%s]
94array(3) {
95  ["Blah"]=>
96  string(12) "Hello World!"
97  ["Foo"]=>
98  bool(false)
99  ["Guff"]=>
100  int(1234567890)
101}
102Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";]
103Close [%s,PHPSESSID]
104Garbage collection..
105Open [%s,PHPSESSID]
106Read [%s,%s]
107int(0)
108Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";]
109Close [%s,PHPSESSID]
110Cleanup..
111Open [%s,PHPSESSID]
112Read [%s,%s]
113Destroy [%s,%s]
114Close [%s,PHPSESSID]
115