Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6177003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:11:54+00:00 2026-05-24T00:11:54+00:00

I am currently building a PHP application using the MVC pattern. I have implemented

  • 0

I am currently building a PHP application using the MVC pattern.

I have implemented role based access control (RBAC) in the application. Currently user priveleges are determined using about 7 joins and then cached in the user’s session. Sessions are stored in the database.

The privilges can be imagined to be a table containing these columns:

  • Module
  • Controller
  • Action
  • Type
  • Object ID
  • Status ID

When I need to match a privilege, Module, Controller, Action and Status ID, must match an exact entry in the table, with “Object ID” being optional depending on “Type”.

Assuming taht on average I will have 100 privileges per user, is it more efficient to cache in the sessions variable in the database, and then use PHP’s array function to parse the cached result?

Or would be it be more efficient to do those joins and determine whether one is allowed to perform that action everytime there is a request?

Cheers 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:11:55+00:00Added an answer on May 24, 2026 at 12:11 am

    The joins will likely be slower, especially if you have lots of users or perms (because it will cause the server to use temporary tables once the cache space is used up).

    If the permissions are rarely changed, then it makes sense to just stick it in the session for the duration of a session. Note that you can also time out the permissions and check every hour or whenever if you want, which gives a compromise.

    On the other hand, if you’re very paranoid or perms change often (eg, right here on stackoverflow), a solution is to use a computed table view to store the results of the joins such that the actual joins are computed on change, not on access. Another option depending on the DB is to use triggers to maintain a “computed” version of the permission that is recalculated every time the source tables change.

    I would use serialize on the array to turn it into text, by the way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently building an MVC application in PHP (not using any frameworks). I
I am currently building an application using ASP.NET MVC. The data entry pages are
I am currently building a small web application for publishing stories using PHP and
I am currently building a gallery web application using php. I am currently developping
I am currently building an application in PHP using CodeIgniter. Usually, in .NET applications,
I am currently building a web site and I just implemented SqlCacheDependency using LinqToSQL
I'm currently designing an application using PHP and MySQL, built on the Kohana framework.
Using PHP, I am building an application that is MySQL database resource heavy, but
I have several classes in an application that I am currently building, and I
I am currently building a Flex 4 web app using PHP as my backend.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.