summaryrefslogtreecommitdiff
path: root/ext/session/tests/bug78624.phpt
blob: 9055b5af7b899704bfe54644066d12775d7cc6b6 (plain)
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
--TEST--
Test session_set_save_handler() : session_gc() returns the number of deleted records.
--INI--
session.name=PHPSESSID
session.save_handler=files
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php

ob_start();

/*
 * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true])
 * Description : Sets user-level session storage functions
 * Source code : ext/session/session.c
 */

echo "*** Test session_set_save_handler() : session_gc() returns the number of deleted records. ***\n";

class MySession implements SessionHandlerInterface {
    public function open($path, $name) {
        echo 'Open', "\n";
        return true;
    }
    public function read($key) {
        echo 'Read ', session_id(), "\n";
        return '';
    }
    public function write($key, $data) {
        echo 'Write ', session_id(), "\n";
        return true;
    }
    public function close() {
        echo 'Close ', session_id(), "\n";
        return true;
    }
    public function destroy($key) {
        echo 'Destroy ', session_id(), "\n";
        return true;
    }
    public function gc($ts) {
        echo 'Garbage collect', "\n";
        return 1;
    }
}

$handler = new MySession;
session_set_save_handler($handler);
session_start();
var_dump(session_gc());
session_write_close();

--EXPECTF--
*** Test session_set_save_handler() : session_gc() returns the number of deleted records. ***
Open
Read %s
Garbage collect
int(1)
Write %s
Close %s