session bug or feature

From: Date: Thu, 07 Aug 2003 11:45:34 +0000
Subject: session bug or feature
Groups: php.general 
Request: Send a blank email to php-general+get-158680@lists.php.net to get a copy of this message
Hey Everyone, I am running Apache 2.047 with PHP (as module) 4.3.2. I ran into something interesting and I wanted to know if it was a bug, or actually supposed to be that way. Given the following lines of code: <?php session_start(); // lets say this equals "bar" and it was set on a previous page $_SESSION["foo"]; $foo = "rab"; echo $_SESSION["foo"]; ?> The problem is, when I set the global variable $foo="rab", when I echo the session variable $_SESSION["foo"], it outputs "rab" instead of "bar"?! This doesn't seem right? If that is the intended behavior, is there anyway to avoid this (perhaps a php.ini directive)? It was a nightmare finding out why my session variables values were being changed by like-named global variables ;-) Hey PHP still rocks though, later Christian

« previous php.general (#158680) next »