1--TEST--
2Test session_set_save_handler() function : basic functionality
3--INI--
4session.save_path=
5session.name=PHPSESSID
6--SKIPIF--
7<?php include('skipif.inc'); ?>
8--FILE--
9<?php
10
11ob_start();
12
13/*
14 * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc)
15 * Description : Sets user-level session storage functions
16 * Source code : ext/session/session.c
17 */
18
19echo "*** Testing session_set_save_handler() : basic functionality ***\n";
20
21require_once "save_handler.inc";
22var_dump(session_module_name());
23var_dump(session_module_name(FALSE));
24var_dump(session_module_name("blah"));
25var_dump(session_module_name("foo"));
26
27$path = dirname(__FILE__);
28session_save_path($path);
29session_set_save_handler("open", "close", "read", "write", "destroy", "gc");
30
31session_start();
32$_SESSION["Blah"] = "Hello World!";
33$_SESSION["Foo"] = FALSE;
34$_SESSION["Guff"] = 1234567890;
35var_dump($_SESSION);
36
37session_write_close();
38session_unset();
39var_dump($_SESSION);
40
41echo "Starting session again..!\n";
42session_id($session_id);
43session_set_save_handler("open", "close", "read", "write", "destroy", "gc");
44session_start();
45var_dump($_SESSION);
46$_SESSION['Bar'] = 'Foo';
47session_write_close();
48
49ob_end_flush();
50?>
51--EXPECTF--
52*** Testing session_set_save_handler() : basic functionality ***
53
54string(%d) "%s"
55
56Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d
57bool(false)
58
59Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d
60bool(false)
61
62Warning: session_module_name(): Cannot find named PHP session module (foo) in %s on line %d
63bool(false)
64Open [%s,PHPSESSID]
65Read [%s,%s]
66array(3) {
67  ["Blah"]=>
68  string(12) "Hello World!"
69  ["Foo"]=>
70  bool(false)
71  ["Guff"]=>
72  int(1234567890)
73}
74Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
75Close [%s,PHPSESSID]
76array(3) {
77  ["Blah"]=>
78  string(12) "Hello World!"
79  ["Foo"]=>
80  bool(false)
81  ["Guff"]=>
82  int(1234567890)
83}
84Starting session again..!
85Open [%s,PHPSESSID]
86Read [%s,%s]
87array(3) {
88  ["Blah"]=>
89  string(12) "Hello World!"
90  ["Foo"]=>
91  bool(false)
92  ["Guff"]=>
93  int(1234567890)
94}
95Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";]
96Close [%s,PHPSESSID]
97