Answer the question
In order to leave comments, you need to log in
What are some articles about sessions in php that you can trust?
I am new to php. Googled authorization\registration on php.
I found this article on Habré.
Everything is simple and clear, it works and is safe. But I need almost the same article only with the implementation of authorization on sessions.
Yes, there is Google - it did not give anything. And what he gave - everywhere in the comments they write about a ton of holes. I need a secure way.
Yes, there is documentation for php where everything is also clearly described, but there is not a single full-fledged example of implementing authorization and registration on the site. Of course, I could try to write my own form using the reference book - but 1. I'm afraid that I will make even more holes than in any example that I found, and 2. - I understand better by examples. Simple code with comments and nothing more is fine.
Answer the question
In order to leave comments, you need to log in
Authorization on sessions is no different from authorization on cookies, except that the session itself generates a hash and sets a cookie.
So if you think this code is safe, then just replace setting and checking the cookie with setting and checking the session variable.
Here are a couple of interesting articles on this topic:
blgo.ru/blog/2014/07/18/regform
blgo.ru/blog/2014/07/24/regform-112
In general, the algorithm is something like this:
We turn on https, hash the password during registration with salt and a static key. More or less like this:
$staticKey = "Your static key";
$salt = %random string with diggits%;
$password = sha1($_POST['password'] . $staticKey . $salt);
// save to db $salt and $password
$staticKey = "Your static key";
$salt = %salt from db%;
$password = sha1($_POST['password'] . $staticKey . $salt);
return $password == $dbPassword; // Авторизация удалась
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question