I'm writing a website backend that will support several users, and every user will have a certain flag for whatever they have access to. I'm trying to come up with a good way to maintain this information.
I was thinking about storing the answer as an integer and then to check flags, I would convert the integer to binary and compare that to a key. For example if my key is
A=1, B=2, C=3, D=4
1011 would mean the user has access to A,B, and D. (read right to left)
Which when stored, would be 11. This seems fine but my variable would have to be a rather large one. (I'm storing the data in a MySQL database) After the number of flags hit a certain size, I'd cap out. I'm guessing around 40 (maybe my math is just off)
Anyone have any ideas one what the best way to handle this problem could be?
Thanks in advance...
-Justin