xref: /PHP-8.1/ext/session/tests/003.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("test003");
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
26$_SESSION["baz"]->method();
27$_SESSION["arr"][3]->method();
28
29var_dump($_SESSION["baz"]);
30var_dump($_SESSION["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