In my php application there are two users named as Admin and User. My login page has left side menues and i want to hide some menues to User.I want to use session and how can i do that? Could you please help me?
Using sessions in php
Collapse
X
-
Well, assuming you know how to use sessions:
[php]
# after a log in
# set a session for Admin or User
$_SESSION['Access'] = "Admin";
# this case is Admin
[/php]
[php]
# show menus?
if($_SESSION['Access'] == "Admin")
{
# include menus
include("admin_ menu.php");
}
else
{
include("user_m enu.php");
}
[/php]
hope this helps! -
Originally posted by markusn00bWell, assuming you know how to use sessions:
[php]
# after a log in
# set a session for Admin or User
$_SESSION['Access'] = "Admin";
# this case is Admin
[/php]
[php]
# show menus?
if($_SESSION['Access'] == "Admin")
{
# include menus
include("admin_ menu.php");
}
else
{
include("user_m enu.php");
}
[/php]
hope this helps!
Thanks for your reply. But how can i check whether Admin or User. Database has User type field and by using username and password can i do that?Comment
-
Well, you'll need a login script for that.Originally posted by ghjkThanks for your reply. But how can i check whether Admin or User. Database has User type field and by using username and password can i do that?
(When the user logs in, you find what access level they have, then assign that to a session)
Do you have one?Comment
-
Originally posted by markusn00bWell, you'll need a login script for that.
(When the user logs in, you find what access level they have, then assign that to a session)
Do you have one?
Could you give me some turorial or link ? Because i'm new to php and still confusing in using sessions.Comment
-
Sure thing, tizag have a good tutorial on sessionsOriginally posted by ghjkCould you give me some turorial or link ? Because i'm new to php and still confusing in using sessions.Comment
Comment