1--TEST--
2Test session_set_save_handler() function : test lazy_write
3--INI--
4session.lazy_write=1
5session.save_path=
6session.name=PHPSESSID
7session.gc_probability=0
8session.save_handler=files
9--SKIPIF--
10<?php include('skipif.inc'); ?>
11--FILE--
12<?php
13
14ob_start();
15
16/*
17 * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc)
18 * Description : Sets user-level session storage functions
19 * Source code : ext/session/session.c
20 */
21
22echo "*** Testing session_set_save_handler() : test write short circuit ***\n";
23
24require_once "save_handler.inc";
25$path = dirname(__FILE__);
26session_save_path($path);
27session_set_save_handler("open", "close", "read", "write", "destroy", "gc", "create_sid", "validate_sid", "update");
28
29session_start();
30$session_id = session_id();
31$_SESSION["Blah"] = "Hello World!";
32$_SESSION["Foo"] = FALSE;
33$_SESSION["Guff"] = 1234567890;
34var_dump($_SESSION);
35
36session_write_close();
37session_unset();
38var_dump($_SESSION);
39
40echo "Starting session again..!\n";
41session_id($session_id);
42session_set_save_handler("open", "close", "read", "write", "destroy", "gc", "create_sid", "validate_sid", "update");
43session_start();
44var_dump($_SESSION);
45$_SESSION['Bar'] = 'Foo';
46session_write_close();
47
48echo "Starting session again..!\n";
49session_id($session_id);
50session_set_save_handler("open", "close", "read", "write", "destroy", "gc", "create_sid", "validate_sid", "update");
51session_start();
52var_dump($_SESSION);
53// $_SESSION should be the same and should skip write()
54session_write_close();
55
56echo "Cleanup\n";
57session_start();
58session_destroy();
59
60ob_end_flush();
61?>
62--EXPECTF--
63*** Testing session_set_save_handler() : test write short circuit ***
64
65Open [%s,PHPSESSID]
66CreateID [PHPT-%s]
67Read [%s,%s]
68array(3) {
69  ["Blah"]=>
70  string(12) "Hello World!"
71  ["Foo"]=>
72  bool(false)
73  ["Guff"]=>
74  int(1234567890)
75}
76Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
77Close [%s,PHPSESSID]
78array(3) {
79  ["Blah"]=>
80  string(12) "Hello World!"
81  ["Foo"]=>
82  bool(false)
83  ["Guff"]=>
84  int(1234567890)
85}
86Starting session again..!
87Open [%s,PHPSESSID]
88Read [%s,%s]
89array(3) {
90  ["Blah"]=>
91  string(12) "Hello World!"
92  ["Foo"]=>
93  bool(false)
94  ["Guff"]=>
95  int(1234567890)
96}
97Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";]
98Close [%s,PHPSESSID]
99Starting session again..!
100Open [%s,PHPSESSID]
101Read [%s,%s]
102array(4) {
103  ["Blah"]=>
104  string(12) "Hello World!"
105  ["Foo"]=>
106  bool(false)
107  ["Guff"]=>
108  int(1234567890)
109  ["Bar"]=>
110  string(3) "Foo"
111}
112Update [%s,PHPT-%d]
113Close [%s,PHPSESSID]
114Cleanup
115Open [%s,PHPSESSID]
116Read [%s,PHPT-%d]
117Destroy [%s,PHPT-%d]
118Close [%s,PHPSESSID]
119