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 = dirname(__FILE__);
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 "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(): Cannot find named PHP session module () in %s on line %d
64bool(false)
65
66Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d
67bool(false)
68
69Warning: session_module_name(): Cannot find named PHP session module (foo) 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]
104Cleanup..
105Open [%s,PHPSESSID]
106Read [%s,%s]
107Destroy [%s,%s]
108Close [%s,PHPSESSID]
109