#32496 [Bgs]: Session string values are references
| From: | ceo at l-i-e dot com | Date: | Fri, 01 Apr 2005 00:12:42 +0000 |
| Subject: | #32496 [Bgs]: Session string values are references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-76144@lists.php.net to get a copy of this message | ||
ID: 32496
User updated by: ceo at l-i-e dot com
Reported By: ceo at l-i-e dot com
Status: Bogus
Bug Type: Session related
Operating System: FreeBSD 5.3-RELEASE
PHP Version: 5.0.3
New Comment:
Fixed in CVS, I guess.
Others have confirmed the bug in 5.0.3 on non FreeBSD platforms.
Previous Comments:
------------------------------------------------------------------------
[2005-03-30 07:25:38] sniper@php.net
Using latest CVS + register_globals = Off -> Works just fine.
------------------------------------------------------------------------
[2005-03-30 05:23:22] ceo at l-i-e dot com
Description:
------------
<?php
session_start();
if (!isset($_SESSION['name'])){
$_SESSION['name'] = 'Richard Lynch';
}
else{
$name = $_SESSION['name'];
}
/* Assume a ton of code goes here */
$name = 'Fooey';
echo "Session name is: ", $_SESSION['name'], "<br />\n";
?>
Now, hit this page, re-load it, and what do *YOU* expect
$_SESSION['name'] to output?
A) 'Richard Lynch', because you never re-assigned $_SESSION['name']
B) 'Fooey' because $name is a reference, and you changed it, so that
changed your session data.
*I* expected A)
Alas, the reality is B)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32496&edit=1