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. Quote 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 Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/256611-sessions/#findComment-1315489 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.