Managing Logged in users
I have a small application I'm working on which that allows users to log in. I have about 12 pages and only logged in user can see 3 of those pages. My question is how do I manage the access so that admins can see all the pages while ordinary logged in users can see fewer of those authenticated pages?
What I'm basically asking for here is how to manage access based on permission? User logs in, they see user management page, but when someone with admin right logs in, they should have more options. Do I need to add some code in the header of all the pages or something?
Any help w开发者_运维百科ill be appreciated.
just add permission field into database and select it
if ($_SESSION['logged_in_user_is'] == "admin"){
//show all of them
}
elseif ($_SESSION['logged_in_user_is'] == "normal user"){
// show some of them
}
else{
//she/he's unlogged, do whatever you want here
}
Presuming you are running Apache, take a look at using htaccess files to manage authorizations: http://httpd.apache.org/docs/current/howto/auth.html
精彩评论