xref: /PHP-8.2/ext/session/tests/003.phpt (revision adb45a63)
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    public $yes;
20    function method() { $this->yes++; }
21}
22
23session_id("test003");
24session_start();
25session_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;}}');
26
27$_SESSION["baz"]->method();
28$_SESSION["arr"][3]->method();
29
30var_dump($_SESSION["baz"]);
31var_dump($_SESSION["arr"]);
32session_destroy();
33?>
34--EXPECT--
35object(foo)#1 (2) {
36  ["bar"]=>
37  string(2) "ok"
38  ["yes"]=>
39  int(2)
40}
41array(1) {
42  [3]=>
43  object(foo)#2 (2) {
44    ["bar"]=>
45    string(2) "ok"
46    ["yes"]=>
47    int(2)
48  }
49}
50