php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28966 Session var is overwritten by regular var of same name
Submitted: 2004-06-30 00:52 UTC Modified: 2004-06-30 17:29 UTC
From: dgoodman at twentythreeg dot net Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.7 OS: Debian/Linux 2.6.5
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dgoodman at twentythreeg dot net
New email:
PHP Version: OS:

 

 [2004-06-30 00:52 UTC] dgoodman at twentythreeg dot net
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



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-30 09:08 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

.
 [2004-06-30 16:53 UTC] dgoodman at twentythreeg dot net
Certainly seems like a bug to me.  I wasn't asking for support.  Please explain how this is does not imply a problem with PHP.

If I assign a value to the session variable, I don't expect to be able to overwrite the value of that variable with a completely unrelated variable.  Please recheck this issue.
 [2004-06-30 17:28 UTC] dgoodman at twentythreeg dot net
My apologies...

Somehow register_globals was turned on when I could have sworn it was turned off.  Sorry to waste your time.
 [2004-06-30 17:29 UTC] derick@php.net
And that's why we used the quick fix that this didn't imply a bug in PHP and pointed you to resources on how to obtain further help.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 21:01:35 2025 UTC