开发者

FormsAuthentication Rememberme

开发者 https://www.devze.com 2023-01-26 03:54 出处:网络
I am using forms authentication and the I wanted the remember me functionality. How can I just retain the username alone.

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

精彩评论

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