1--TEST--
2Test session_set_save_handler() : implicit shutdown
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() : implicit shutdown ***\n";
14
15class MySession extends SessionHandler {
16    public $num;
17    public function __construct($num) {
18        $this->num = $num;
19        echo "(#$this->num) constructor called\n";
20    }
21    public function __destruct() {
22        echo "(#$this->num) destructor called\n";
23    }
24    public function finish() {
25        $id = session_id();
26        echo "(#$this->num) finish called $id\n";
27        $this->shutdown();
28    }
29    public function write($id, $data) {
30        echo "(#$this->num) writing $id = $data\n";
31        return parent::write($id, $data);
32    }
33    public function close() {
34        $id = session_id();
35        echo "(#$this->num) closing $id\n";
36        return parent::close();
37    }
38}
39
40$handler = new MySession(1);
41session_set_save_handler($handler);
42session_start();
43
44$_SESSION['foo'] = 'bar';
45
46// implicit close
47echo "done\n";
48ob_end_flush();
49?>
50--EXPECTF--
51*** Testing session_set_save_handler() : implicit shutdown ***
52(#1) constructor called
53done
54(#1) writing %s = foo|s:3:"bar";
55(#1) closing %s
56(#1) destructor called
57