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 ***
60
61string(0) ""
62*** Without lazy_write ***
63bool(true)
64Open [%s,PHPSESSID]
65CreateID [PHPT-%d]
66Read [%s,PHPT-%d]
67GC [0]
681 deleted
69bool(true)
70string(%d) "PHPT-%d"
71Write [%s,PHPT-%d,]
72Close [%s,PHPSESSID]
73NULL
74string(%d) "PHPT-%d"
75*** With lazy_write ***
76string(%d) "PHPT-%d"
77bool(true)
78Open [%s,PHPSESSID]
79ValidateID [%s,PHPT-%d]
80Read [%s,PHPT-%d]
81GC [0]
821 deleted
83bool(true)
84Write [%s,PHPT-%d,]
85Close [%s,PHPSESSID]
86NULL
87string(%d) "PHPT-%d"
88*** Cleanup ***
89string(%d) "PHPT-%d"
90Open [%s,PHPSESSID]
91ValidateID [%s,PHPT-%d]
92Read [%s,PHPT-%d]
93GC [0]
941 deleted
95bool(true)
96Destroy [%s,PHPT-%d]
97
98Warning: unlink(%s): No such file or directory in %s on line %d
99Close [%s,PHPSESSID]
100bool(true)
101