cookies vs sessions for php application

后端 未结 4 2037
猫巷女王i
猫巷女王i 2021-01-15 11:08

what would be better when implementing a php login system sessions or cookies ?

4条回答
  •  庸人自扰
    2021-01-15 11:45

    Save in cookies:

    1. $user_id
    2. $hash=hash('sha512',$salt.$ip.$user_id)

    And on authentication check if hash of user_id is equal to hash stored in cookies. In this way you don`t have to store anything in server side.

提交回复
热议问题