xref: /PHP-7.3/ext/session/tests/006.phpt (revision 782352c5)
1--TEST--
2correct instantiation of references between variables in sessions
3--SKIPIF--
4<?php include('skipif.inc'); ?>
5--INI--
6session.use_cookies=0
7session.use_strict_mode=0
8session.cache_limiter=
9session.serialize_handler=php
10session.save_handler=files
11--FILE--
12<?php
13error_reporting(E_ALL);
14ob_start();
15
16session_id("abtest");
17session_start();
18
19class a {
20    public $test = "hallo";
21}
22
23class b {
24    public $a;
25    function __construct(&$a) {
26        $this->a = &$a;
27    }
28}
29
30$a = new a();
31$b = new b($a);
32
33echo "original values:\n";
34var_dump($a,$b);
35
36$_SESSION["a"] = $a;
37$_SESSION["b"] = $b;
38session_write_close();
39
40unset($_SESSION["a"], $_SESSION["b"]);
41
42session_start();
43
44echo "values after session:\n";
45var_dump($a,$b);
46
47session_destroy();
48?>
49--EXPECTF--
50original values:
51object(a)#%d (1) {
52  ["test"]=>
53  string(5) "hallo"
54}
55object(b)#%d (1) {
56  ["a"]=>
57  &object(a)#%d (1) {
58    ["test"]=>
59    string(5) "hallo"
60  }
61}
62values after session:
63object(a)#%d (1) {
64  ["test"]=>
65  string(5) "hallo"
66}
67object(b)#%d (1) {
68  ["a"]=>
69  &object(a)#%d (1) {
70    ["test"]=>
71    string(5) "hallo"
72  }
73}
74