2000-12-24 16:33:27 +00:00
|
|
|
--TEST--
|
|
|
|
session_set_save_handler test
|
2002-03-08 19:16:19 +00:00
|
|
|
--SKIPIF--
|
2002-04-19 07:55:24 +00:00
|
|
|
<?php include('skipif.inc'); ?>
|
2002-10-03 08:07:21 +00:00
|
|
|
--INI--
|
2002-10-03 15:11:01 +00:00
|
|
|
session.use_cookies=0
|
|
|
|
session.cache_limiter=
|
2002-10-03 08:07:21 +00:00
|
|
|
register_globals=1
|
2002-10-13 11:14:49 +00:00
|
|
|
session.name=PHPSESSID
|
2002-11-25 23:20:05 +00:00
|
|
|
session.serialize_handler=php
|
2000-12-24 16:33:27 +00:00
|
|
|
--FILE--
|
2001-10-06 09:54:23 +00:00
|
|
|
<?php
|
2002-10-03 16:14:55 +00:00
|
|
|
error_reporting(E_ALL);
|
2000-12-24 16:33:27 +00:00
|
|
|
|
|
|
|
class handler {
|
2007-08-23 11:42:21 +00:00
|
|
|
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;}}';
|
2000-12-24 16:33:27 +00:00
|
|
|
function open($save_path, $session_name)
|
|
|
|
{
|
2002-01-10 05:11:19 +00:00
|
|
|
print "OPEN: $session_name\n";
|
2000-12-24 16:33:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
function close()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
function read($key)
|
|
|
|
{
|
|
|
|
print "READ: $key\n";
|
2001-01-07 10:40:41 +00:00
|
|
|
return $GLOBALS["hnd"]->data;
|
2000-12-24 16:33:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function write($key, $val)
|
|
|
|
{
|
|
|
|
print "WRITE: $key, $val\n";
|
2001-01-07 10:40:41 +00:00
|
|
|
$GLOBALS["hnd"]->data = $val;
|
2000-12-24 16:33:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function destroy($key)
|
|
|
|
{
|
|
|
|
print "DESTROY: $key\n";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function gc() { return true; }
|
|
|
|
}
|
|
|
|
|
|
|
|
$hnd = new handler;
|
|
|
|
|
|
|
|
class foo {
|
2003-11-30 13:57:20 +00:00
|
|
|
public $bar = "ok";
|
2000-12-24 16:33:27 +00:00
|
|
|
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"));
|
|
|
|
|
2002-01-10 05:11:19 +00:00
|
|
|
session_id("abtest");
|
2000-12-24 16:33:27 +00:00
|
|
|
session_start();
|
|
|
|
$baz->method();
|
|
|
|
$arr[3]->method();
|
|
|
|
|
|
|
|
var_dump($baz);
|
|
|
|
var_dump($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();
|
|
|
|
|
2001-01-07 10:40:41 +00:00
|
|
|
var_dump($baz);
|
|
|
|
var_dump($arr);
|
|
|
|
|
2000-12-24 16:33:27 +00:00
|
|
|
session_destroy();
|
2001-07-13 10:32:37 +00:00
|
|
|
?>
|
2000-12-24 16:33:27 +00:00
|
|
|
--EXPECT--
|
2002-01-10 05:11:19 +00:00
|
|
|
OPEN: PHPSESSID
|
|
|
|
READ: abtest
|
2003-05-31 13:10:00 +00:00
|
|
|
object(foo)#2 (2) {
|
2000-12-24 16:33:27 +00:00
|
|
|
["bar"]=>
|
|
|
|
string(2) "ok"
|
|
|
|
["yes"]=>
|
|
|
|
int(2)
|
|
|
|
}
|
|
|
|
array(1) {
|
|
|
|
[3]=>
|
2003-05-31 13:10:00 +00:00
|
|
|
object(foo)#3 (2) {
|
2000-12-24 16:33:27 +00:00
|
|
|
["bar"]=>
|
|
|
|
string(2) "ok"
|
|
|
|
["yes"]=>
|
|
|
|
int(2)
|
|
|
|
}
|
|
|
|
}
|
2002-01-10 05:11:19 +00:00
|
|
|
WRITE: abtest, 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: abtest
|
2003-05-31 13:10:00 +00:00
|
|
|
object(foo)#4 (2) {
|
2001-01-07 10:40:41 +00:00
|
|
|
["bar"]=>
|
|
|
|
string(2) "ok"
|
|
|
|
["yes"]=>
|
|
|
|
int(2)
|
|
|
|
}
|
|
|
|
array(1) {
|
|
|
|
[3]=>
|
2003-05-31 13:10:00 +00:00
|
|
|
object(foo)#2 (2) {
|
2001-01-07 10:40:41 +00:00
|
|
|
["bar"]=>
|
|
|
|
string(2) "ok"
|
|
|
|
["yes"]=>
|
|
|
|
int(2)
|
|
|
|
}
|
|
|
|
}
|
2002-01-10 05:11:19 +00:00
|
|
|
DESTROY: abtest
|