xref: /PHP-8.0/ext/session/tests/023.phpt (revision 7aacc705)
1--TEST--
2session object deserialization
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);
14
15class foo {
16    public $bar = "ok";
17    function method() { $this->yes++; }
18}
19
20session_id("abtest");
21session_start();
22session_decode('baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}');
23$baz = $_SESSION['baz'];
24$arr = $_SESSION['arr'];
25
26$baz->method();
27$arr[3]->method();
28
29var_dump($baz);
30var_dump($arr);
31session_destroy();
32?>
33--EXPECT--
34object(foo)#1 (2) {
35  ["bar"]=>
36  string(2) "ok"
37  ["yes"]=>
38  int(2)
39}
40array(1) {
41  [3]=>
42  object(foo)#2 (2) {
43    ["bar"]=>
44    string(2) "ok"
45    ["yes"]=>
46    int(2)
47  }
48}
49