Proper way to use “Remember me” functionality in PHP

后端 未结 4 458
礼貌的吻别
礼貌的吻别 2021-02-04 05:46

Short

Working on login system and trying to implement remember me feature.

Recently, l did research about this subject, read bunch of articles, posts, stories, n

4条回答
  •  别跟我提以往
    2021-02-04 06:18

    But I really confused about my main problem: which way is proper, for "remember me" feature? to use cookies/session/database?

    Http is a stateless protocall. Authentication token must persist to keep the state. Proper way is to use session. Now how do you track the session? It's up to you. But cookies are not bad.

    In the session you can save a hash created from browser different criteria(user agent, os, screen resolution etc) to check if the token is from same environment. The more criteria you save the more itll be harder to hijack. Btw you need JavaScript to grab ths extra information every time.

提交回复
热议问题