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
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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.