Session variable not showing up in other pages
Posted: Thu Sep 06, 2007 9:11 am
Hey guys...
I have a php page that creates a session variable called $_SESSION['key'] and I want this session variable to be accessible in another page that links to it. Easy enough, right?
Well, just to be clear, the header file included in each of these pages does indeed contain session_start(); before anything else, so that isn't the problem.
Here is the page that sets the Session variable:
Here is the page2.php that links to the page where the Session variable $_SESSION['key'] is created.
Any ideas why page2.php doesn't recognize $_SESSION['key'] at all? This is stumping me big time. Any help is GREATLY appreciated. Thanks guys.
I have a php page that creates a session variable called $_SESSION['key'] and I want this session variable to be accessible in another page that links to it. Easy enough, right?
Well, just to be clear, the header file included in each of these pages does indeed contain session_start(); before anything else, so that isn't the problem.
Here is the page that sets the Session variable:
Code: Select all
# Start Output Buffering:
ob_start();
# Initialize Session
session_start();
$_SESSION['key'] = md5('gobleygook');
if (isset($_SESSION['key']) && $_SESSION['key'] = md5('gobleygook'))
echo '<h1>SESSION HAS BEEN SET</h1>'; // This actually outputs in the browser, so I know the session is indeed being set correctly.
echo '<a href="page2.php">Go To Page 2</a>';
# Flush the buffered output:
ob_end_flush();Here is the page2.php that links to the page where the Session variable $_SESSION['key'] is created.
Code: Select all
# Start Output Buffering:
ob_start();
# Initialize Session
session_start();
if (isset($_SESSION['key']) && $_SESSION['key'] = md5('gobleygook')) // THIS FAILS!!!
echo '<h1>SESSION HAS BEEN SET</h1>'; // This DOES NOT output.
# Flush the buffered output:
ob_end_flush();