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