1--TEST--
2Test session_set_save_handler() : inheritance
3--INI--
4session.save_handler=files
5session.name=PHPSESSID
6--EXTENSIONS--
7session
8--SKIPIF--
9<?php include('skipif.inc'); ?>
10--FILE--
11<?php
12
13ob_start();
14
15echo "*** Testing session_set_save_handler() : inheritance ***\n";
16
17class MySession3 extends SessionHandler {
18    public $i = 0;
19    public function open($path, $name): bool {
20        ++$this->i;
21        return parent::open($path, $name);
22    }
23    public function read($key): string|false {
24        ++$this->i;
25        return parent::read($key);
26    }
27}
28
29class MySession4 extends MySession3 {
30    public function write($id, $data): bool {
31        $this->i = "hai";
32        return parent::write($id, $data);
33    }
34}
35
36$handler = new MySession3;
37session_set_save_handler($handler);
38session_start();
39
40$_SESSION['foo'] = "hello";
41
42session_write_close();
43session_unset();
44
45session_start();
46
47var_dump($_SESSION, $handler->i);
48
49session_write_close();
50session_unset();
51
52$handler = new MySession4;
53session_set_save_handler($handler);
54
55session_start();
56
57$_SESSION['bar'] = 'hello';
58session_write_close();
59session_unset();
60
61var_dump(session_id(), $_SESSION, $handler->i);
62?>
63--EXPECTF--
64*** Testing session_set_save_handler() : inheritance ***
65array(1) {
66  ["foo"]=>
67  string(5) "hello"
68}
69int(4)
70string(%d) "%s"
71array(2) {
72  ["foo"]=>
73  string(5) "hello"
74  ["bar"]=>
75  string(5) "hello"
76}
77string(3) "hai"
78