I am creating a web app for a business which includes several departments. I am using PHP and MySql to do this, in my database i am storing the privileges as ENUM with options N (No access), R (Read Only) and RW (Read and Write).
Once a user logs in, a php script finds the appropriate privileges and stores those in a session. For example: if a user has RW for Production, then there is a session variable $_SESSION['production'] = RW. Now whenever i need to see if a user is allowed to edit production then i check with the session variable and take appropriate actions.
I have 20 such categories of privileges. This certainly isn’t the way store something like this. This will simply increase the load time and hog plenty of memory. Are there any alternatives to store the user rights?
Note: The 20 category list is expected to grow.
I typically use
to keep the memory requirements in context: 100 privileges, the name consisting of 20 chars, the value of 5 chars, will add up to less than a page (4k). The load time issue is heavily mitgated by PHP using a very efficient bnary serializer on session files.