sanchez77 Posted February 7, 2012 Share Posted February 7, 2012 So I'm trying to understand Sessions and how to store a variable within a session. What I want to t do, is start a session, check if variable is set, if not, set the variable. So with the code below, I start the session, i check the variable, if not set, i set it. But when i refrsh the page, it has the same session id but it didn't store the session variable from the previous load. Please, what am I missing? <?php session_start(); echo "Session ID: ".session_id()."<br>"; echo "<br>chktrack Pre: ".$_session['chktrack'].""; if ($_session['chktrack'] != 1){ $_session['chktrack']=1; } echo "<br>chktrack Post: ".$_session['chktrack'].""; echo "<br><a href='index.php'>Index</a>"; ?> Thanks in advance for your help. Link to comment https://forums.phpfreaks.com/topic/256611-sessions/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 7, 2012 Share Posted February 7, 2012 Php variables are case-sensitive. It's $_SESSION Link to comment https://forums.phpfreaks.com/topic/256611-sessions/#findComment-1315486 Share on other sites More sharing options...
sanchez77 Posted February 7, 2012 Author Share Posted February 7, 2012 Thanks, that was it. Link to comment https://forums.phpfreaks.com/topic/256611-sessions/#findComment-1315489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.