如何永久登录我的网站 [英] How to log in forever in my website
本文介绍了如何永久登录我的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用表单身份验证.我想让用户永远登录,直到他明确注销为止,该如何在配置中进行设置?
谢谢.
Hi,
I''m used forms authentication. I want to keep user log in forever until he log out explicit, how can I set this in configuration?
thanks.
推荐答案
尝试使用cookie.例如
Try using cookies. E.g.,
Response.Cookies["username"].Value=textBoxUsername.Text;
Response.Cookies["username"].Expires=DateTime.Now.AddDays(30);
这是一种方式.您也可以使用
This is one way. You can also use
HttpCookie cookie=new HttpCookie();
cookie.Value=textBoxUsername.Text;
cookie.Expires=DateTime.Now.AddDays(30);
Response.Cookies.Add(cookie);
这些是使用cookie的简单方法.在我的示例中,cookie的创建期限为30天.
Those are simple ways of using cookies. In my examples, the cookie expires 30 days from creation.
您可以用来将登录状态完全存储在会话中,也可以将其存储在cookie中.这样,您可以将到期时间设置为所需的任何时间,如果需要,他们可以保持登录一天或一周,或者永久登录.
有关详细信息,请访问那里 [
You can use to storing login state in the session entirely, and store it in a cookie instead. That way, you could set the expiry to whatever you wanted, and they could stay logged in for a day, or a week, or forever, if you wanted.
for details have a go there[^] to read discussion.
http://msdn.microsoft.com/en-us/library/system.web.configuration .formsauthenticationconfiguration.timeout.aspx [ ^ ]
http://stackoverflow.com/questions/1637001/forms-authentication-permanent-login-option-along-with-non-persistant-option-with [
http://msdn.microsoft.com/en-us/library/system.web.configuration.formsauthenticationconfiguration.timeout.aspx[^]
http://stackoverflow.com/questions/1637001/forms-authentication-permanent-login-option-along-with-non-persistant-option-with[^]
I hope the above information will be helpful. If you have more concerns, please let me know.
这篇关于如何永久登录我的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文