1--TEST--
2Test session_set_save_handler() function : variation
3--INI--
4session.use_strict_mode=1
5session.gc_probability=1
6session.gc_divisor=1
7session.gc_maxlifetime=0
8session.save_path=
9session.name=PHPSESSID
10session.save_handler=files
11--SKIPIF--
12<?php include('skipif.inc'); ?>
13--FILE--
14<?php
15
16ob_start();
17
18/*
19 * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc)
20 * Description : Sets user-level session storage functions with validate_id() and update()
21 * Source code : ext/session/session.c
22 */
23
24function noisy_gc($maxlifetime) {
25	echo("GC [".$maxlifetime."]\n");
26	echo gc($maxlifetime)." deleted\n";
27	return true;
28}
29
30echo "*** Testing session_set_save_handler() : variation ***\n";
31
32require_once "save_handler.inc";
33$path = dirname(__FILE__);
34var_dump(session_save_path($path));
35
36echo "*** Without lazy_write ***\n";
37var_dump(session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc", "create_sid", "validate_sid", "update"));
38var_dump(session_start(['lazy_write'=>FALSE]));
39$session_id = session_id();
40var_dump(session_id());
41var_dump(session_write_close());
42var_dump(session_id());
43
44echo "*** With lazy_write ***\n";
45var_dump(session_id($session_id));
46var_dump(session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc", "create_sid", "validate_sid", "update"));
47var_dump(session_start(['lazy_write'=>TRUE]));
48var_dump(session_commit());
49var_dump(session_id());
50
51echo "*** Cleanup ***\n";
52var_dump(session_id($session_id));
53var_dump(session_start());
54var_dump(session_destroy());
55
56ob_end_flush();
57?>
58--EXPECTF--
59*** Testing session_set_save_handler() : variation ***
60string(0) ""
61*** Without lazy_write ***
62bool(true)
63Open [%s,PHPSESSID]
64CreateID [PHPT-%d]
65Read [%s,PHPT-%d]
66GC [0]
671 deleted
68bool(true)
69string(%d) "PHPT-%d"
70Write [%s,PHPT-%d,]
71Close [%s,PHPSESSID]
72bool(true)
73string(%d) "PHPT-%d"
74*** With lazy_write ***
75string(%d) "PHPT-%d"
76bool(true)
77Open [%s,PHPSESSID]
78ValidateID [%s,PHPT-%d]
79Read [%s,PHPT-%d]
80GC [0]
811 deleted
82bool(true)
83Write [%s,PHPT-%d,]
84Close [%s,PHPSESSID]
85bool(true)
86string(%d) "PHPT-%d"
87*** Cleanup ***
88string(%d) "PHPT-%d"
89Open [%s,PHPSESSID]
90ValidateID [%s,PHPT-%d]
91Read [%s,PHPT-%d]
92GC [0]
931 deleted
94bool(true)
95Destroy [%s,PHPT-%d]
96
97Warning: unlink(%s): No such file or directory in %s on line %d
98Close [%s,PHPSESSID]
99bool(true)
100