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"];
}
精彩评论