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