Working on very big project and trying to create optimal database usage. I heard that it's not recomended to save user id's in $_SESSION variables. I can actually work with only tokens, this tokens are assigned to user id's in database. The problem is, if I will work with only tokens, I need to do 1 extra operation (query) with database inside script. So the question is, may I save user id inside $_SESSION variables to prevent ectra database operations? How "dangerous" it might be?
Thx in advance.
Yes, you may. The session is stored on the server and therefore just about as safe as any other server-side storage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With