From:             dgoodman at twentythreeg dot net
Operating system: Debian/Linux 2.6.5
PHP version:      4.3.7
PHP Bug Type:     Session related
Bug description:  Session var is overwritten by regular var of same name

Description:
------------
If I save a variable to $_SESSION, for example $_SESSION['varname'] =
'value', and then assign a value to a normal variable of the same name,
$varname = 'value2', then the value of the session variable is overwritten
with the second value.

This is not an issue of assignment by reference -- I assign values, as
shown in the code I have provided.

The first time the code is executed, the results are correct on my
machine.  However, on subsequent executions of the code, the results
become incorrect.

Reproduce code:
---------------
<?PHP

session_start();

$_SESSION['var'] = 'Foo';
print 'Session.var = '.$_SESSION['var'].'<BR>';

$var = 'Bar';
print 'var = '.$var.'<BR>';

$var1 = $_SESSION['var'];
print 'var1 = '.$var1.'<BR>';


?>

Expected result:
----------------
Session.var = Foo
var = Bar
var1 = Foo

Actual result:
--------------
Session.var = Foo
var = Bar
var1 = Bar



-- 
Edit bug report at http://bugs.php.net/?id=28966&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28966&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28966&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28966&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28966&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28966&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28966&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28966&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28966&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28966&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28966&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28966&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28966&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28966&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28966&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28966&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28966&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28966&r=float

Reply via email to