D
D
demortall2021-05-16 13:10:00
PHP
demortall, 2021-05-16 13:10:00

Is it possible to make such an authorization?

It is necessary that during authorization write down cookies.
For example: a person logged in, data was found in mysql. And according to this data, the id and role of the person are read, and written into cookies.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
none7, 2021-05-16
@none7

It is possible if this data is encrypted with a decent crypto algorithm. Naturally, the encryption key must be generated from /dev/random and changed regularly. We also store the key id in the cookie (not the check-sum), and on the server all the previously used keys. You can also replace encryption with a hash using a similar temporary key. If the key is very rotten, then we do not trust it. But I strongly advise you not to write roles in cookies, because if a person's privileges were taken away, the cookie entry will still remain with role=admin. Traditional sessions are much more reliable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question