HOME

Monday, February 6, 2012

Implement Remember Password in asp.net

protected void Page_Load(object sender, EventArgs e)
{
if (HttpContext.Current.Request.Cookies["cookiename"] != null)
{
txtUserName.Text = HttpContext.Current.Request.Cookies["cookiename"]["LoginName"].ToString();
txtPassword.Text = HttpContext.Current.Request.Cookies["cookiename"]["Password"].ToString();

}

}

protected void Button1_Click(object sender, ImageClickEventArgs e)

{
if (chkRemeber.Checked == true)
{
HttpCookie cookie = new HttpCookie("cookiename");
cookie.Values.Add("LoginName", txtUserName.Text);
cookie.Values.Add("Password", txtPassword.Text);
cookie.Expires = DateTime.Now.AddDays(30);

 }

1 comment:

  1. grate article... continue with more example.good luck

    ReplyDelete