1--TEST--
2Test session_set_save_handler() function: class with create_sid
3--INI--
4session.save_handler=files
5session.name=PHPSESSID
6--SKIPIF--
7<?php include('skipif.inc'); ?>
8--FILE--
9<?php
10
11ob_start();
12
13echo "*** Testing session_set_save_handler() function: class with create_sid ***\n";
14
15class MySession2 extends SessionHandler {
16    public $path;
17
18    public function open($path, $name) {
19        if (!$path) {
20            $path = sys_get_temp_dir();
21        }
22        $this->path = $path . '/u_sess_' . $name;
23        return true;
24    }
25
26    public function close() {
27        return true;
28    }
29
30    public function read($id) {
31        return (string)@file_get_contents($this->path . $id);
32    }
33
34    public function write($id, $data) {
35        return (bool)file_put_contents($this->path . $id, $data);
36    }
37
38    public function destroy($id) {
39        @unlink($this->path . $id);
40    }
41
42    public function gc($maxlifetime) {
43        foreach (glob($this->path . '*') as $filename) {
44            if (filemtime($filename) + $maxlifetime < time()) {
45                @unlink($filename);
46            }
47        }
48        return true;
49    }
50
51    public function create_sid() {
52        return pathinfo(__FILE__)['filename'];
53    }
54}
55
56$handler = new MySession2;
57session_set_save_handler($handler);
58session_start();
59
60$_SESSION['foo'] = "hello";
61
62var_dump(session_id(), ini_get('session.save_handler'), $_SESSION);
63
64session_write_close();
65session_unset();
66
67session_start();
68var_dump($_SESSION);
69--CLEAN--
70<?php
71@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_class_017');
72?>
73--EXPECT--
74*** Testing session_set_save_handler() function: class with create_sid ***
75string(34) "session_set_save_handler_class_017"
76string(4) "user"
77array(1) {
78  ["foo"]=>
79  string(5) "hello"
80}
81array(1) {
82  ["foo"]=>
83  string(5) "hello"
84}
85