Jump to content

[SOLVED] Best way for permissions


cheechm

Recommended Posts

Hello,

I was wondering what the best way of doing permissions would be.

IE I have this in my config.php file:

 

define("ADMIN", 9);
define("REVIEWER", 0);
define("EDITOR", 0);
define("USER",  1);
define("GUEST", 0);

 

How would I be able to set permissions for each page? Also if I want to edit them from a user interface would it be best to store in a MySQL table?

 

Can you point me to tutorials?

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/72004-solved-best-way-for-permissions/
Share on other sites

How would I be able to set permissions for each page? Also if I want to edit them from a user interface would it be best to store in a MySQL table?

 

you'll want to use SESSIONS. have the user log in using a user name and password stored in a table along with the user level, 'permissions', for that user. when the user logs in, set a session variable defining that user's permissions, ala $_SESSION['permissions'] = 1;

 

when the user visits a protected page, check the value set for that user's permissions:

 

if ($_SESSION['permissions'] < 1) {

      echo "You don't have permission.";

      exit;

} else {

      echo "You DO have permission.";

     

      // continue processing

 

 

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.