the permissions themselves wouldn't have a value between 4 and 8. A user level might though. Let's assume a user has a level of 5.Everah wrote:What happens when you want to add a permission in between 4 and 8?
in binary that's:
Code: Select all
0101the cool thing is you can save a user's permission level as an integer on the db (or in a session var) and compare it against the binary permissions using the & operator as Begby outlined above.
so for permission privilege '4':
a user with permission level 5 would match
a user with permission level 6 would match
a user with permission level 7 would match
a user with permission level 8 would not match
etc...