xref: /PHP-7.2/ext/session/tests/026.phpt (revision 17ccbeec)
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;
38
39session_write_close();
40unset($_SESSION['a']);
41unset($_SESSION['b']);
42
43session_start();
44$a = $_SESSION['a'];
45$b = $_SESSION['b'];
46echo "values after session:\n";
47var_dump($a,$b);
48session_destroy();
49?>
50--EXPECTF--
51original values:
52object(a)#%d (1) {
53  ["test"]=>
54  string(5) "hallo"
55}
56object(b)#%d (1) {
57  ["a"]=>
58  &object(a)#%d (1) {
59    ["test"]=>
60    string(5) "hallo"
61  }
62}
63values after session:
64object(a)#%d (1) {
65  ["test"]=>
66  string(5) "hallo"
67}
68object(b)#%d (1) {
69  ["a"]=>
70  &object(a)#%d (1) {
71    ["test"]=>
72    string(5) "hallo"
73  }
74}
75