Jump to content

Trouble checking SESSION cookie


jmr3460

Recommended Posts

I am trying to use $_SESSION cookies to verify admin privileges .

I don't understand why this is not working:

/*everything above here is working*/
$session = mysql_fetch_array($session_query);
$type = $session['admin_type'];
$name = $session['admin_name'];
$level = $session['admin_level'];
$_SESSION['type'] = $type;
$_SESSION['name'] = $name;
$_SESSION['level'] = $level;
/*This is returning false*/
  if(isset($_SESSION['type']))
{
    if($_SESSION['type'] == 'regional')
{
header('Location: all_admin.php');
exit();
}
}

What am I not doing right.

Link to comment
https://forums.phpfreaks.com/topic/185046-trouble-checking-session-cookie/
Share on other sites

echo these values and check, also do one thing. use the

unset($_SESSION['type']);unset($_SESSION['name']);unset($_SESSION['level']);

to unset the cookies and clear ur browser and check it out again..

if possible paste ur entire code back here..

so that it would be useful to resolve it properly

OK thanks for the fast reply. This block of script is supposed to redirect the user to the regional admin page if the $_SESSION ['type'] is set to regional. When I echo $_SESSION['type'] it echos regional so the session type is set to the correct name I just need the block to return true so the redirect will happen.

Sorry for your troubles. I found it. I have been changing some things with the site. I am moving the admin folder to another and I am changing $_COOKIE (which is easy but not as versatile) to $_SESSION. I had an if statement checking for $_COOKIE in front  of the $_SESSION. Thanks for the replies though.

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.