phppup Posted June 12, 2022 Share Posted June 12, 2022 I know this may seem trivial, but it's like to handle this correctly from a load bearing and a db rules standpoint. My scenario: a user has several buttons that can access information IF the user is authorized. There is a good chance that the user will click (and come back) several buttons during a session. Does it make sense to put the entire set $AUTH1, AUTH2, etc. into $_SESSION when running the initial SELECT statement in order to save trips to the database? Our should a separate SELECT be introduced each time? Analogy: I went to the basement and brought up soda, fruit juice, and bottled water. I only needed water, but there was a good chance I'd need another option later, and wanted to avoid the trip up and down the stairs. I don't suppose my code gets tired, LOL, but traffic is traffic. Recommendations? Quote Link to comment https://forums.phpfreaks.com/topic/314918-trips-to-the-database/ Share on other sites More sharing options...
mac_gyver Posted June 12, 2022 Share Posted June 12, 2022 4 minutes ago, phppup said: IF the user is authorized because the user's authorization can change (promoted, demoted, banned) between page requests, you should always query on each page request to get the current user information/permissions. Quote Link to comment https://forums.phpfreaks.com/topic/314918-trips-to-the-database/#findComment-1597218 Share on other sites More sharing options...
phppup Posted June 12, 2022 Author Share Posted June 12, 2022 22 minutes ago, mac_gyver said: because the user's authorization can change (promoted, demoted, banned) Not that type of environment. And that is why I'm more concerned regarding the example I outlined in my analogy. Quote Link to comment https://forums.phpfreaks.com/topic/314918-trips-to-the-database/#findComment-1597220 Share on other sites More sharing options...
maxxd Posted June 13, 2022 Share Posted June 13, 2022 (edited) OK, so when you went down to the basement your parents had previously said it was ok for you to drink soda. You weren't looking for - and at that point didn't want to drink any - soda but you decided (understandably) that you might want some later, so you brought it up. Cool. Problem is, between the time you brought the soda up from the basement and the time you decided you actually wanted to drink it, your parents decided you shouldn't have it. Check permissions every time you do something or expect bad things to happen. If someone logs in with certain rights and abilities, don't expect they'll log out before you change those rights and abilities. Edited June 13, 2022 by maxxd Quote Link to comment https://forums.phpfreaks.com/topic/314918-trips-to-the-database/#findComment-1597225 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.