开发者

FormsAuthentication Rememberme

I am using forms authentication and the I wanted the remember me functionality. How can I just retain the username alone.

I wanted the username to be stored on cookies and when the开发者_如何学编程 user is logged out. I want to user name to be displayed on the username text box.

Is there an example that can be provided?


In the login method (Probably your "Login" button click):

Response.Cookies["userName"].Value = txtUserName.Text;

Then on the Page_Load check for that cookie and assign the textbox a value.

if (!String.IsNullOrEmpty(Request.Cookies["userName"])) {
   txtUserName.Text = Request.Cookies["userName"];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜