即使关闭浏览器,用户如何登录... [英] how the user be logged in even if he closes the browser...

查看:120
本文介绍了即使关闭浏览器,用户如何登录...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好
我希望用户即使在浏览器关闭后也能保持登录状态
我该怎么做
现在我要做的是
System.Web.Security.FormsAuthentication.SetAuthCookie(userName,true);
但不幸的是,当浏览器关闭时,用户将被注销...
我不想做的
帮我plz

hello
i want the user to be remain logged in even after the browser will be closed
how can i do that
uptill now what i have done is
System.Web.Security.FormsAuthentication.SetAuthCookie(userName, true);
but unfortunatelly when the browser is closed the user will be loged out...
that i dont want to do
help me plz

推荐答案

这不是正确的方法. SetAuthCookie仅对当前浏览器会话有效.大多数浏览器都具有允许用户记住"凭据的功能,并且这些凭据以加密形式保存在用户的计算机上.让他们使用浏览器执行此操作.

您可以尝试使用Google.我搜索了"asp.net记住我的功能",并返回了超过240万个结果:

http://forums.asp.net/t/1087450.aspx/1?ASP + Login + Remember + Me +功能 [ ^ ]
This is a not the correct way to do it. SetAuthCookie is only valid for the current browser session. Most browsers have functionality to allow the user to "remember" credentials, and those credentials are kept in encrypted form on the user''s machine. Let them use the browser to do this.

You could try using google. I searched for "asp.net remember me functionality", and got back more than 2.4 million results back:

http://forums.asp.net/t/1087450.aspx/1?ASP+Login+Remember+Me+functionality[^]


"asp.net记住我的功能"只会记住密码,但密码不给你,您在寻找什么.
只需尝试以下步骤

1.将您的用户名和密码放入Cookies

2.在登录页面的LOAD上,只需检查您的Cookie是否已存储该机器的用户名和密码,如果是,则直接重定向到菜单"页面而不是登录页面.

3.如果用户按LOGOUT按钮销毁该cookie.
"asp.net remember me functionality" will just remember the password but it''s not give you, what u searching for.
Just try folllwing steps

1. Put your Username and password in Cookies

2. on LOAD of login page just check your cookies has username and password stored for that machin, If yes the directly redirect to Menu page not login page.

3. if user press LOGOUT button destroy that cookies.


您可以通过设置持久性cookie来实现.不过请注意,如果您走这条路,用户将保持登录"状态(这意味着,即使他们的会话超时,您的应用程序也可以在他们下次出现时识别它们).

不幸的是,持久性cookie行为已从System.Web.Security.FormsAuthentication中删除.但是不要放松睡眠,有一种方法可以实现您想要的.让这作为您的指南. http://geekswithblogs.net/vivek/archive/2006/10/13/93956.aspx [^ ]
You can achieve this my setting a persistent cookie. Mind you though, if you go this path, the user will remain "logged" ( means, even though their session is timed out, you application will be able to recognize them, next time they come around)

unfortunately, persist cookie behavior is removed from System.Web.Security.FormsAuthentication. But don''t loose a sleep there is a way to achieve what you want. Let this be your guide. http://geekswithblogs.net/vivek/archive/2006/10/13/93956.aspx[^]


这篇关于即使关闭浏览器,用户如何登录...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆