实施“记住我” ASP.NET 中的功能
在 ASP.NET 网站上实现“记住我
”功能的最佳方法是什么?
我应该使用自定义cookie还是有更简单的方法?
What is the best way to implement 'remember me
' functionality on an ASP.NET web site?
Should I use custom cookies or is there a simpler method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否使用 ASP.NET 提供的内置
身份验证
服务?如果是这样,那就很容易了。Are you using the built in
Authenication
services provided by ASP.NET? If so, its pretty easy.对我来说,解决方案是区分浏览器会话 cookie(不要与 asp.net 会话 cookie 混淆)和持久 cookie - 设置较低的过期时间将创建一个持久 cookie,这意味着当浏览器关闭并重新启动时它会被记住。 - 在有效期内打开。以下对我有用:
For me the solution was differentiating between a browser-session cookie (not to be confused with the asp.net session cookie) and a persistent one - setting a low expiration will create a persistent cookie meaning it gets remembered when the browser is closed and re-opened within the expiration time. The following works for me: