#23732 [NEW]: Assignment to global variable overwrites session-value
| From: | daniel dot burckhardt at sur-gmbh dot ch | Date: | Wed, 21 May 2003 09:32:11 +0000 |
| Subject: | #23732 [NEW]: Assignment to global variable overwrites session-value | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-40122@lists.php.net to get a copy of this message | ||
From: daniel dot burckhardt at sur-gmbh dot ch
Operating system: Linux
PHP version: 4.3.1
PHP Bug Type: Session related
Bug description: Assignment to global variable overwrites session-value
(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 bug report at http://bugs.php.net/?id=23732&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23732&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23732&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23732&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23732&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23732&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23732&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23732&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23732&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23732&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23732&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23732&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23732&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23732&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23732&r=gnused