I have about 15-20 permission settings that are loaded when a user logs in. These are each stored as a session with a value of 1 or 0.
I’m wondering, would it be better to have one session like $_SESSION['permissions'] with a value of: dothis:0,dothat:1,doanother:1, etc. (one large string) which I can explode and seperate later on with PHP, or would it be best to have all these as separate sessions with just a value of 1 or 0?
Rather than a string to parse, store them as an array in
$_SESSION. This makes it much easier to modify individual permissions without having to do piles of string operations.Addendum
You might have figured this out already, but I thought I would add that it is easiest to interact with these via a few tiny functions. These will save a lot of typing (and typing errors), and make sure the values all end up as booleans.
The you can just call them as: