简体   繁体   English

如何保持登录状态

[英]How do keep signed in works

I would like to know how the "Keep Signed In" works and how it is achieved. 我想知道“保持登录状态”如何工作以及如何实现。 Suppose I have enabled keep signed in on an website. 假设我启用了保持登录网站的功能。 So if I open that web site even after restarting my machine then it will auto sign in. 因此,即使重新启动计算机后仍打开该网站,它将自动登录。

How this can be achieved with java. 用Java如何做到这一点。

After signing in, you could create a unique string, place it in the database along with the user ID who signed in, then store it as a cookie on the browser. 登录后,您可以创建一个唯一的字符串,将其与登录的用户ID一起放置在数据库中,然后将其作为cookie存储在浏览器中。 Next time the user visits the site, if he's not signed in, then read the value of the cookie and see if a user is present in the database with that value. 下次用户访问该网站时(如果尚未登录),请读取Cookie的值,并查看该数据库中是否存在用户。 If so, sign him in and continue. 如果是这样,请登录并继续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM