简体   繁体   English

用Java管理Cookie

[英]Managing cookies in Java

What's the best practice to implement sign in "Remember Me" feature in Java? 在Java中实现“记住我”功能的最佳实践是什么?

Obviously, storing cookies with username and password in user's browser is not secure enough. 显然,在用户浏览器中存储带有用户名和密码的cookie不够安全。 Create authentication token in cookies and db instead? 而是在Cookie和数据库中创建身份验证令牌? Any simple examples? 有简单的例子吗?

Take a look at the Spring Security framework . 看一下Spring Security框架 You can achieve this scenario with a few lines of configuration. 您可以通过几行配置来实现此方案。

I'll second the suggestion of using Spring Security. 我将推荐使用Spring Security的建议。 It comes with a couple of different implementations for managing the token stored in the cookie on the users's browser. 它带有几个不同的实现,用于管理用户浏览器中cookie中存储的令牌。

http://static.springframework.org/spring-security/site/reference/html/remember-me.html http://static.springframework.org/spring-security/site/reference/html/remember-me.html

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

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