|
-
Dec 22nd, 2003, 05:01 AM
#1
Thread Starter
Frenzied Member
Sessions and admin/users
Hi,
I'm using sessions for a members area of the website but when a users has logged in how do i work out if the user is a admin or a user???
I'm using a mysql database!!
-
Dec 22nd, 2003, 05:12 AM
#2
Hyperactive Member
Why dont you just store the permission along with the user name in a table? Create a table permissions, for example with 1 Administrator, 2 User, 3 Superuser whatever diffrences you make, and assign every user the matching permision.
Dont know if thats the correct way but it works.
HTH, Stephan
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
-
Dec 22nd, 2003, 05:24 AM
#3
Thread Starter
Frenzied Member
yip i have that but when a page loads after they log on how does it work out with the sessions if the person is an admin or user??
-
Dec 22nd, 2003, 10:48 AM
#4
Originally posted by kiwis
yip i have that but when a page loads after they log on how does it work out with the sessions if the person is an admin or user??
You can have another session variable that contains the administration level of the user. Then, depeding upon the value of that, you perform different actions, show/hide different links.
-
Dec 22nd, 2003, 12:56 PM
#5
Stuck in the 80s
Maybe I'm not understanding the problem...but can't you use the session username to search the table and find the permission field for that user?
Code:
$users = mysql_query("SELECT * FROM userTable WHERE username='" . $_SESSION['username'] . "'") or die(mysql_error());
if ($user = mysql_fetch_array($users)) {
//validate user (password and such)
//get user permission ($user['permission'] or something)
} else {
//invalid session information
}
That's how I'd do it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|