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 = dirname(__FILE__);
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 ***
54
55Open [%s,PHPSESSID]
56Read [%s,%s]
57GC [0]
581 deleted
59array(3) {
60  ["Blah"]=>
61  string(12) "Hello World!"
62  ["Foo"]=>
63  bool(false)
64  ["Guff"]=>
65  int(1234567890)
66}
67Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
68Close [%s,PHPSESSID]
69NULL
70Open [%s,PHPSESSID]
71Read [%s,%s]
72GC [0]
731 deleted
74array(3) {
75  ["Blah"]=>
76  string(12) "Hello World!"
77  ["Foo"]=>
78  bool(false)
79  ["Guff"]=>
80  int(1234567890)
81}
82Destroy [%s,%s]
83
84Warning: unlink(%s): No such file or directory in %s on line %s
85Close [%s,PHPSESSID]
86bool(true)
87
88