Designing a secure auto login cookie system in PHP

后端 未结 3 1150
予麋鹿
予麋鹿 2020-12-01 11:05

I want to have an auto login option check for a user. Basically that means a cookie will be stored on the client side.

Now the question is, how do I make it secure s

3条回答
  •  感情败类
    2020-12-01 11:59

    The way I have previously done this is storing the MD5 hash of the password not the actual password.

    On the server side you need to check if the login is coming from a cookie and then check if the hash is the same as the password in your database after its been hashed through MD5

    That way if someone hacks the users computer they can never know the value of the password however the can still use that cookie to authenticate to only your server.

    You can make this more secure by making the cookie expire after x days so if the cookie is stolen the theif can only get access for that period.

    At the end of the day the most and only? secure method is make the user login each time

提交回复
热议问题