xref: /PHP-8.1/ext/session/tests/023.phpt (revision b5a14e6c)
1--TEST--
2session object deserialization
3--EXTENSIONS--
4session
5--SKIPIF--
6<?php include('skipif.inc'); ?>
7--INI--
8session.use_cookies=0
9session.use_strict_mode=0
10session.cache_limiter=
11session.serialize_handler=php
12session.save_handler=files
13--FILE--
14<?php
15error_reporting(E_ALL);
16
17class foo {
18    public $bar = "ok";
19    function method() { $this->yes++; }
20}
21
22session_id("test023");
23session_start();
24session_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;}}');
25$baz = $_SESSION['baz'];
26$arr = $_SESSION['arr'];
27
28$baz->method();
29$arr[3]->method();
30
31var_dump($baz);
32var_dump($arr);
33session_destroy();
34?>
35--EXPECT--
36object(foo)#1 (2) {
37  ["bar"]=>
38  string(2) "ok"
39  ["yes"]=>
40  int(2)
41}
42array(1) {
43  [3]=>
44  object(foo)#2 (2) {
45    ["bar"]=>
46    string(2) "ok"
47    ["yes"]=>
48    int(2)
49  }
50}
51