$_SESSION issues

From: Date: Fri, 09 May 2003 04:16:18 +0000
Subject: $_SESSION issues
Groups: php.general 
Request: Send a blank email to php-general+get-146965@lists.php.net to get a copy of this message
I need some clarification here please. Maybe not the greatest thing to do, but I'm just testing and this shows contradictory results in the piece that doesn't work.. This works: page1.php session_start(); $test = "Test stuff"; $_SESSION['GLOBALS']; page2.php session_start(); $var = "test"; $$var = $_SESSION[$var]; echo $test; //outputs: Test stuff This doesn't work: page2.php session_start(); foreach($_SESSION as $var => $val) { $$var = $val; echo $var; //output: many keys but NEVER test } echo $test; //gives Notice: Undefined variable: test print_r($_SESSION); //outputs: many keys including [test] => 'Test stuff' if(array_key_exists("test", $_SESSION)) { echo "TEST FOUND"; //outputs: TEST FOUND } What gives? TIA -Shawn

« previous php.general (#146965) next »