#23732 [Opn->Bgs]: Assignment to global variable overwrites session-value
| From: | mgf@php.net | Date: | Wed, 21 May 2003 11:06:55 +0000 |
| Subject: | #23732 [Opn->Bgs]: Assignment to global variable overwrites session-value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-40127@lists.php.net to get a copy of this message | ||
ID: 23732
Updated by: mgf@php.net
Reported By: daniel dot burckhardt at sur-gmbh dot ch
-Status: Open
+Status: Bogus
Bug Type: Session related
Operating System: Linux
PHP Version: 4.3.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is expected behaviour: at version 4.3.0, a defect was corrected so
that now the global variable and the $_SESSION[] entry always reference
the same value. (In versions 4.1 and 4.2 this was not the case, which
could lead to unexpected and non-intuitive results.)
Previous Comments:
------------------------------------------------------------------------
[2003-05-21 04:32:11] daniel dot burckhardt at sur-gmbh dot ch
(this seems to be the same problem as in
Bug #20709 Session variable getting mysteriously set
which has been closed)
When register_globals is On, the assignment
$foo = 'bar';
has the side-effect of setting
$_SESSION['foo'] = 'bar';
The following script shows this - enter a new value into the
input-field and watch how $_SESSION['foo'] changes.
<?php
session_start();
if($_POST['submit'] != 'go') {
if(empty($_SESSION['foo']))
$_SESSION['foo'] = 'foo';
}
else
$foo = $_POST['foo']; // This assignment overwrites $_SESSION['foo']
if and only if register_globals is on
?>
<html>
<body>
<?php echo 'Session:'.$_SESSION['foo'] ?>
<form action="session_test.php" method="post">
<input type="text" name="foo" />
<input type="submit" name="submit" value="go" />
</form>
</body>
</html>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23732&edit=1