I want to make an authorization system, but I do not fully understand how much the system with COOKIE is safe. I do this:
- user logs in, enters login and password
- we "salt" the password with a login and save the hash function in the database
- when the user enters his login and password to log in, we again get the hash function from the login and password just entered and compare the value with the function that we have in the database
- if these hashes match, then we salt this hash on time or on ip and give the resulting value as COOKIE to the user. And the same value is written to the database in a cookie column for example.
- and now when a user visits our website, we check if he has a COOKIE and compare them with the value that we recorded in the cookie column in our database.
- if these cookies match, then the user is successfully authorized.
And it turns out that if these cookies are taken from the browser and copied to another computer and access our website from this other computer, the server will check if there is a COOKIE with this value in our database and, if so, then skip the user without any problems. And even if we specify the validity of COOKIE one day for example. We then recorded this cookie value in the database forever. It will not be removed from the database in a day. And theoretically, if an attacker once acquired the value of a COOKIE, then he will always be able to enter the site and be considered authorized. If someone can clarify the situation. I would be very happy. Thank !