php - What should I store in cookies to implement "Remember me" during user login -
I have a login system for my website, user details stored in the database email address < / Strong> (unique), display name (not unique), password and members .
Now what should I store in cookies? I was thinking of storing a user's cookie with an expiration date and then if the user comes back to my website after signing up for a cookie and logging in (how do I look right ) And delete the cookie if it decides to log out.
* A small explanation will also be very helpful thanks, you can only store the user ID in the cookie if you sign it with a secret key which only know your application otherwise it will not show any cookies for the user. It is possible to change and login as someone else. Therefore, if you want to store user-aid, you also want to store a hash of user id with secret key (ideally used) and when you want to log in them, calculate the same hash and Compare the cookie to hash. Another solution is to generate a random token, store it in the database and use it in that cookie if it is long and random enough, then there is very little chance that someone can guess the token of another person.
Comments
Post a Comment