Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- session_set_save_handler test --EXTENSIONS-- session --SKIPIF-- <?php include('sk..
Decoded Output download
--TEST--
session_set_save_handler test
--EXTENSIONS--
session
--SKIPIF--
<?php include('skipif.inc'); ?>
--INI--
session.use_cookies=0
session.use_strict_mode=0
session.cache_limiter=
session.name=PHPSESSID
session.serialize_handler=php
--FILE--
<?php
error_reporting(E_ALL);
ob_start();
class handler {
public $data = '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;}}';
function open($save_path, $session_name): bool
{
print "OPEN: $session_name
";
return true;
}
function close(): bool
{
return true;
}
function read($key): string|false
{
print "READ: $key
";
return $GLOBALS["hnd"]->data;
}
function write($key, $val): bool
{
print "WRITE: $key, $val
";
$GLOBALS["hnd"]->data = $val;
return true;
}
function destroy($key): bool
{
print "DESTROY: $key
";
return true;
}
function gc() { return true; }
}
$hnd = new handler;
class foo {
public $bar = "ok";
function method() { $this->yes++; }
}
session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc"));
session_id("test004");
session_start();
$_SESSION["baz"]->method();
$_SESSION["arr"][3]->method();
var_dump($_SESSION["baz"]);
var_dump($_SESSION["arr"]);
session_write_close();
session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc"));
session_start();
var_dump($_SESSION["baz"]);
var_dump($_SESSION["arr"]);
session_destroy();
?>
--EXPECT--
OPEN: PHPSESSID
READ: test004
object(foo)#2 (2) {
["bar"]=>
string(2) "ok"
["yes"]=>
int(2)
}
array(1) {
[3]=>
object(foo)#3 (2) {
["bar"]=>
string(2) "ok"
["yes"]=>
int(2)
}
}
WRITE: test004, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}}
OPEN: PHPSESSID
READ: test004
object(foo)#3 (2) {
["bar"]=>
string(2) "ok"
["yes"]=>
int(2)
}
array(1) {
[3]=>
object(foo)#2 (2) {
["bar"]=>
string(2) "ok"
["yes"]=>
int(2)
}
}
DESTROY: test004
Did this file decode correctly?
Original Code
--TEST--
session_set_save_handler test
--EXTENSIONS--
session
--SKIPIF--
<?php include('skipif.inc'); ?>
--INI--
session.use_cookies=0
session.use_strict_mode=0
session.cache_limiter=
session.name=PHPSESSID
session.serialize_handler=php
--FILE--
<?php
error_reporting(E_ALL);
ob_start();
class handler {
public $data = '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;}}';
function open($save_path, $session_name): bool
{
print "OPEN: $session_name\n";
return true;
}
function close(): bool
{
return true;
}
function read($key): string|false
{
print "READ: $key\n";
return $GLOBALS["hnd"]->data;
}
function write($key, $val): bool
{
print "WRITE: $key, $val\n";
$GLOBALS["hnd"]->data = $val;
return true;
}
function destroy($key): bool
{
print "DESTROY: $key\n";
return true;
}
function gc() { return true; }
}
$hnd = new handler;
class foo {
public $bar = "ok";
function method() { $this->yes++; }
}
session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc"));
session_id("test004");
session_start();
$_SESSION["baz"]->method();
$_SESSION["arr"][3]->method();
var_dump($_SESSION["baz"]);
var_dump($_SESSION["arr"]);
session_write_close();
session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc"));
session_start();
var_dump($_SESSION["baz"]);
var_dump($_SESSION["arr"]);
session_destroy();
?>
--EXPECT--
OPEN: PHPSESSID
READ: test004
object(foo)#2 (2) {
["bar"]=>
string(2) "ok"
["yes"]=>
int(2)
}
array(1) {
[3]=>
object(foo)#3 (2) {
["bar"]=>
string(2) "ok"
["yes"]=>
int(2)
}
}
WRITE: test004, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}}
OPEN: PHPSESSID
READ: test004
object(foo)#3 (2) {
["bar"]=>
string(2) "ok"
["yes"]=>
int(2)
}
array(1) {
[3]=>
object(foo)#2 (2) {
["bar"]=>
string(2) "ok"
["yes"]=>
int(2)
}
}
DESTROY: test004
Function Calls
None |
Stats
MD5 | 8dbd764c2b2303aa3b996d2db7f774a9 |
Eval Count | 0 |
Decode Time | 71 ms |