#22117 [Opn]: Session vars inappropriately created as references

From: Date: Sun, 09 Feb 2003 22:07:54 +0000
Subject: #22117 [Opn]: Session vars inappropriately created as references
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-32605@lists.php.net to get a copy of this message
ID: 22117 User updated by: phpbugs@brianmertens.com Reported By: phpbugs@brianmertens.com Status: Open Bug Type: Session related Operating System: Win NT 4 PHP Version: 4.3.0 New Comment: Here's the contents of the session file, immediately after execution of my first test script test_bug1.php, from versions 4.2.2 and 4.3.0: session file from 4.2.2: var1|s:11:"INITIALIZED";var2|s:11:"INITIALIZED"; session file from 4.3.0: var1|s:11:"INITIALIZED";var2|R:1; Previous Comments: ------------------------------------------------------------------------ [2003-02-07 17:41:24] phpbugs@brianmertens.com It took me a while to track this down... we noticed that when we upgraded a develpment box from 4.2.3 to 4.3.0, that one of our session vars was being over-written by another. It turns out that one was being serialized to the session as a reference to the other, but only if the vars were intialized like this: $var1 = $var2 = "some value"; Consider two scripts, test_bug1.php and test_bug2.php If you run test_bug1, and then test_bug2, surprisingly, the output of test_bug2 will be: BEFORE: var1 = 'INITIALIZED' var2 = 'INITIALIZED' AFTER: var1 = 'CHANGED' var2 = 'CHANGED' <?php // test_bug1.php session_start(); $var1 = $var2 = "INITIALIZED"; session_register("var1","var2"); echo "INIT:<br>\n"; echo "var1 = '$var1'<br>"; echo "var2 = '$var2'<br><p>"; echo "<a href='test_bug2.php'>test_bug2.php</a>"; ?> <?php // test_bug2.php session_start(); echo "BEFORE:<br>\n"; echo "var1 = '$var1'<br>\n"; echo "var2 = '$var2'<br><p>\n"; $var2 = "CHANGED"; echo "AFTER:<br>\n"; echo "var1 = '$var1'<br>\n"; echo "var2 = '$var2'<br><p>\n"; $var2 = "EXIT"; ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22117&edit=1

« previous php.bugs (#32605) next »