Why does the session value disappear ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chu2654
Forum Newbie
Posts: 11
Joined: Mon Aug 07, 2006 6:59 pm

Why does the session value disappear ?

Post by chu2654 »

Hello,
I use session as the following. But the session value disappear in main.php. What's the problem ?
$_SESSION["SESSION_TIMESTAMP"] = time();
header("Location:main.php");
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Are you calling session_start() at the top of every page that is using the session?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Sessions setting can be short circuited if you redirect. Try adding a call to session_write_close().
Post Reply