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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.