Frocer
11-20-2007, 10:32 AM
Hi,
I am having a very bizzare problem that I cannot explain. Basically, my session variable is getting lost through pages (header redirect). So here is the sample code:
page1.php
<?php
session_start();
$_SESSION['test'] = 'test';
header('location:page2.php');
exit;
?>
page2.php
<?php
session_start();
echo $_SESSION['test'];
?>
on page2.php, the echo would be empty... and I can't explain why this is happening. After many hours of googling, it seems like a lot of people are having this problem, but I can't find a solution.
Any idea would be much appreciated! Thanks!
I am having a very bizzare problem that I cannot explain. Basically, my session variable is getting lost through pages (header redirect). So here is the sample code:
page1.php
<?php
session_start();
$_SESSION['test'] = 'test';
header('location:page2.php');
exit;
?>
page2.php
<?php
session_start();
echo $_SESSION['test'];
?>
on page2.php, the echo would be empty... and I can't explain why this is happening. After many hours of googling, it seems like a lot of people are having this problem, but I can't find a solution.
Any idea would be much appreciated! Thanks!