I need the site to remember the username and password of the user, how to implement it? I think you can enter its ip and primary key into the database, but is this too primitive? I mean, if the ip of the user is not static, then the site simply will not be able to remember it, TK ip will always be new, in my opinion, will it save the data in such a way - is it a crutch or will it come down? I apologize for a rather abstract question, but I cannot formulate it more precisely.

  • You need to use the session. This is such a mechanism, when you assign a certain identifier to a user, and put this value to him in the cookie session. At the same time, each time a user accesses your site, you can match the incoming person with a unique user based on the contents of this cookie. You can read more here: komotoz.ru/uroki/php/sessii_v_php.php - Evgeniy Shubin
  • Maybe it's about "What exactly identifies a site visitor?" - andreymal

1 answer 1

Standardly, cookies and sessions are used for such things, if you mean (to remember the user), automatic authorization when you re-visit the site (for example, if the user has checked the "Remember me" checkbox), then when registering the user, write his login and hash to the database password generated for example by means of password_hash () , then when using the authorization check whether the entered password matches with the hash in the database, password_verify () , then if the user has set the checkbox "Remember me", create a cookie, and as an option can be written lo in and the hash is encrypted, then to extract the data and substitute for authorization. And what about the IP so it is really useless, as ~ 80% are dynamic, and will change almost every time you reconnect to the network. There is a lot of information about authorization methods and cookies in the network.