0

Hi,

If there are multiple type of users - Super Admin, Admin, Clients should i have to use seperate SESSION variables for each type of users? Or should i have to maintain the session in single variable?


Thanks

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Shanti C
0

Use as many variables as necessary. Just write statements that restrict access based on user level. Example:

if($_SESSION['user']=="Super Admin"){
echo "Welcome Super Admin";
//allow Super Admin to do whatever
}
else{
header ('location:index.php?your_not_allowed_in_here');//do a redirect if access is not allowed
}
0

hello..
add one more field to your login table like type..
and set it 1 as for superadmin, 2 for admin,3 for client...
and register that type field in your session variable like..

//some statements...
$_SESSION['user']=$row['type];

And in your pages:

if($_SESSION['user']=="1"){
     echo "Welcome Super Admin";//or use header to redirect to some page...
   else  if($_SESSION['user']=="2"){
  echo "Welcome  Admin";//or use header to redirect to some page...
       }
         else if($_SESSION['user']=="3"){
        echo "Welcome  Client";//or use header to redirect to some page...
      }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.