Remember me Cookie best practice?

前端 未结 7 1622
感动是毒
感动是毒 2020-12-01 05:30

I read about many old questions about this argument, and I thought that the best practice is to set up a cookie with username,user_id and a random

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 06:04

    My approach is the following:

    1. Hash the user_id
    2. Generate an unique key for the user - md5(current_timestamp)
    3. Save the key to the DB
    4. Encode everything so it looks like a BS - base64
    5. Save it in the cookie

    So far, It has been working great for me :)

提交回复
热议问题