|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-02-23 08:30 UTC] antonio04 at gmail dot com
Description:
------------
When you have a session variable whose whose session array key is
defined but with a NULL value, this variable acts as if register_globals
were enabled, i.e. any value set to a global variable of the same name
is stored in the session as this key's value.
Once the session variable's value has been changed to something not
null, this behavior ceases.
A cursory search in the archives shows that this issue was categorized
as a bogus bug report six years ago (#28482), but the reason given does
not make sense, as the session variable key certainly does exist and
acts unexpectedly when initialized to NULL.
Thanks!
Reproduce code:
---------------
<?php
/* Script 1 */
session_start();
init_set('register_globals', 0);
$_SESSION['foo'] = NULL;
$foo = 'bar';
?>
<?php
/* Script 2 */
session_start();
var_dump($_SESSION['foo']);
?>
Expected result:
----------------
Script 1:
Script 2:
Notice: Undefined index: foo in /home/www/interpals/test.php on line 3
NULL
Actual result:
--------------
Script 1:
Script 2:
string(3) "bar"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 23 01:00:01 2025 UTC |
Sorry, there was a typo in the reproduce code -- please check this instead: <?php /* Script one */ ini_set('register_globals', 0); session_start(); $_SESSION['foo'] = NULL; $foo = 'bar'; ?> Then view the second script: <?php /* Script two */ session_start(); var_dump($_SESSION['foo']); ?>Just to confirm, register_globals is definitely off -- both as reported by phpinfo() as well as the following snippet: <?php echo 'register_globals = ' . ini_get('register_globals') . "\n"; ?> Which displays the following: register_globals =