Julie
Julie

Reputation: 19

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 will be appreciated.

Upvotes: 0

Views: 99

Answers (2)

genesis
genesis

Reputation: 50976

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
}

Upvotes: 2

kroonwijk
kroonwijk

Reputation: 8400

Presuming you are running Apache, take a look at using htaccess files to manage authorizations: http://httpd.apache.org/docs/current/howto/auth.html

Upvotes: 1

Related Questions