ID:               28482
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kraziej at ta2 dot so-net dot ne dot jp
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: linux
 PHP Version:      4.3.6
 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

Setting a value of a session variable to NULL is equivalent 
to the destruction of said session variable. 


Previous Comments:
------------------------------------------------------------------------

[2004-05-22 07:06:21] kraziej at ta2 dot so-net dot ne dot jp

Description:
------------
Hi,
I apologize beforehand if this is a known issue.
I wasn't exactly sure if the behavior was a bug or a feature
since various google search results and mail-list archives
had slight differences in their descriptions.
If anybody can give me some clarity on this issue, it
would be very helpful and certainly appreciated.
Thank you very much in advance.

Using sessions, initializing a variable with NULL and "" (empty string)
gives different results, with "" it behaves as expected but with NULL I
get the warning :

 Warning: Unknown():
 Your script possibly relies on a session side-effect which existed
until PHP 4.2.3. Please be advised that the session extension does not
consider global variables as a source of data, unless register_globals
is enabled.......(goes on)

Yes, I know php changed the way to handle sessions, but
the confusion I have is that why php behaves completely
differently when initializing variables in 2 different
ways.

I get this with php-4.3.(4|5|6) and register_globals is off.
apache-1.3.2x and 1.3.31.
php is compiled into apache (and not by apxs dso module).
OS: linux (glibc-2.2.5 gcc-2.9.6 kernel-2.4.26)


Reproduce code:
---------------
initializing with NULL and "" in test1.php will give different
results.
-- example code of test1.php:
<?
session_start();
$_SESSION['test'] = NULL; # warnings
#$_SESSION['test'] = "";    # expected results
print "<a href=\"test2.php\">link test2.php</a><BR>\n";
?>

-- example code of test2.php:
<?
session_start();
$test = "abcde";
print_r($_SESSION);
?>


Expected result:
----------------
click the link test2.php and:

When initialized with "" I get no warning, and
$_SESSION['test'] and $test are handled as different
variables like expected.
/tmp/sess_............. stays untouched like expected.


Actual result:
--------------
click the link test2.php and:

When initialized with NULL I get the warning.
Whats worse is if I refresh test2.php, the warning
disappears and the value of $_SESSION['test'] gets over-written by
$test.
/tmp/sess_............. also gets written with the
value of $test.

It seems like it behaves as if global_registers
is on (it gets overrided into the "old way") where
$_SESSION['test'] and $test was handled as same
variables.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28482&edit=1

Reply via email to