Jump to content

Sessions


sanchez77

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.