ID: 37926
User updated by: thomas at ecommerce dot com
Reported By: thomas at ecommerce dot com
Status: Open
Bug Type: Session related
Operating System: SuSE Linux 10.0
PHP Version: 5.1.4
New Comment:
Same problem with this Code example:
<?php
ob_Start();
session_start();
var_dump($_SESSION);
$_SESSION['asdf'] = "cool";
$tmp = $_SESSION;
$cool = 'test';
$_SESSION['me'] = $cool;
var_dump($_SESSION);
Previous Comments:
------------------------------------------------------------------------
[2006-06-27 13:39:04] thomas at ecommerce dot com
wrong subject
------------------------------------------------------------------------
[2006-06-27 13:38:25] thomas at ecommerce dot com
Description:
------------
I didn't find anything in the documentation that is related to the
following script. Its not possible to update the $_SESSION var after
the call 'dummy($_SESSION)'.
The var will be set during the runtime, but when you refresh the
page/script, the vars setted after the function call will be gone.
just put the bottom code in an test.php script and run it 1 time and
refresh it again via browser. You will see, second var will be gone
after refresh.
Reproduce code:
---------------
<?php
ob_start(); //-- enshure headers don't get sended
session_start(); //-- start session
//-- dummy function, that make it impossible to set an $_SESSION var
after it
function dummy($var = null)
{
static $tmp = array();
$tmp[] = $var;
}
//-- dump current value
var_dump($_SESSION);
//-- set new value
$_SESSION['test'] = "cool";
//-- call dummy function
dummy($_SESSION);
//-- simeple var
$cool = "yes";
//-- set var in session
$_SESSION['whatever'] = $cool;
//-- dump current value
var_dump($_SESSION);
?>
Expected result:
----------------
Expected result after refresh:
array(2) {
["test"]=>
string(4) "cool"
["whatever"]=>
string(3) "yes"
}
array(2) {
["test"]=>
string(4) "cool"
["whatever"]=>
string(3) "yes"
}
Actual result:
--------------
Current result after refresh:
array(1) {
["test"]=>
string(4) "cool"
}
array(2) {
["test"]=>
string(4) "cool"
["whatever"]=>
string(3) "yes"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37926&edit=1