如何在asp.net 2.0中自动登录用户? [英] How to autologin user in asp.net 2.0?
本文介绍了如何在asp.net 2.0中自动登录用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望用户在记住我复选框后保持登录状态。怎么做?
I want user stayed logged in after remember me checkbox is checked. how to do this?
推荐答案
On button_click
On button_click
if (rememberme.Checked)
{
Response.Cookies["unm"].Value = usernametxt.Text;
Response.Cookies["pwd"].Value = passwordtxt.Text;
Response.Cookies["unm"].Expires = DateTime.Now.AddMonths(1);
Response.Cookies["pwd"].Expires = DateTime.Now.AddMonths(1);
}
else
{
Response.Cookies["unm"].Expires = DateTime.Now.AddMonths(-1);
Response.Cookies["pwd"].Expires = DateTime.Now.AddMonths(-1);
}
这将记住你1个月。
希望这会对你有所帮助。:)
-KR
This will remember you for 1 month.
Hope this would help you.:)
-KR
这篇关于如何在asp.net 2.0中自动登录用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文