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