Jump to content

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

 

 

}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.