1--TEST--
2Test session_set_save_handler() function : variation
3--SKIPIF--
4<?php include('skipif.inc'); ?>
5--INI--
6session.gc_probability=1
7session.gc_divisor=1
8session.gc_maxlifetime=0
9session.save_path=
10session.name=PHPSESSID
11session.save_handler=files
12--FILE--
13<?php
14
15ob_start();
16
17/*
18 * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc)
19 * Description : Sets user-level session storage functions
20 * Source code : ext/session/session.c
21 */
22
23echo "*** Testing session_set_save_handler() : variation ***\n";
24
25function noisy_gc($maxlifetime) {
26	echo("GC [".$maxlifetime."]\n");
27	echo gc($maxlifetime)." deleted\n";
28	return true;
29}
30
31require_once "save_handler.inc";
32$path = __DIR__;
33session_save_path($path);
34session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc");
35
36session_start();
37$_SESSION["Blah"] = "Hello World!";
38$_SESSION["Foo"] = FALSE;
39$_SESSION["Guff"] = 1234567890;
40var_dump($_SESSION);
41$session_id = session_id();
42var_dump(session_write_close());
43
44session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc");
45session_id($session_id);
46session_start();
47var_dump($_SESSION);
48var_dump(session_destroy());
49
50ob_end_flush();
51?>
52--EXPECTF--
53*** Testing session_set_save_handler() : variation ***
54Open [%s,PHPSESSID]
55Read [%s,%s]
56GC [0]
572 deleted
58array(3) {
59  ["Blah"]=>
60  string(12) "Hello World!"
61  ["Foo"]=>
62  bool(false)
63  ["Guff"]=>
64  int(1234567890)
65}
66Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
67Close [%s,PHPSESSID]
68bool(true)
69Open [%s,PHPSESSID]
70Read [%s,%s]
71GC [0]
721 deleted
73array(3) {
74  ["Blah"]=>
75  string(12) "Hello World!"
76  ["Foo"]=>
77  bool(false)
78  ["Guff"]=>
79  int(1234567890)
80}
81Destroy [%s,%s]
82
83Warning: unlink(%s): No such file or directory in %s on line %d
84Close [%s,PHPSESSID]
85bool(true)
86