Forum Moderators: coopster
I'm creating a admin system and what I have is a cookie based login system which works well.
However when the user sucessfully logins in I set them a cookie, but I want to store the user level in a cookie so for instance if that person has a user level set to 1 they will get certain menu items appearing in the main nav.
How do I go about doing this?
Heres some code...
// authorisation code
$result=mysql_query("select user_level from tablename
where userid='$user'
AND password=password('$pass')");
$num=mysql_num_rows($result);
if ($num!= 0)
{
// want to set user level in cookie
$cookie_name = 'auth';
$cookie_value = 'ok';
setcookie ($cookie_name,$cookie_value, time()+3200);
header("Location: main-menu.php");
exit;
}
else
{
header("Location:index.html");
exit;
}
main-menu.php
// displays the menu items.
// checks for cookie
if ($auth == 'ok')
{
// but also check the value of user level here I think
// displays menu items
}
else
{
include('redirect.php');
}
This will be implemented throughout the site because I have a main nav at the top of each page but the nav will display certain menu items depending on value of user level in the cookie.
Thanks for your help :o)