Click here to Skip to main content
15,911,785 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have entered my user name and password and checked remember me ==true, So I created cookies to save username and password. saved but not remembered password when i enter user name and I used...

My Code in Project
C#
protected void LoginButton_Click(object sender, EventArgs e)
       {



           CheckBox RememberPassword = (CheckBox)Login1.FindControl("RememberMe");

           FormsAuthentication.SetAuthCookie(Login1.UserName, RememberPassword.Checked);


           if (RememberPassword.Checked)
           {
               HttpCookie cookie1 = new HttpCookie("MyCookie");
               cookie1.Values.Add("username", Login1.UserName);
               cookie1.Values.Add("password", Login1.Password);
               cookie1.Expires = DateTime.Now.AddDays(2);//cookie Expires
               Response.AppendCookie(cookie1);
               Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, "MyCookie"));

           }

       }

In Page Load

C#
if (HttpContext.Current.Request.Cookies["MyCookie"] != null)
              {
                  if (Request.Cookies["MyCookie"].HasKeys)
                  {
                      //if (Login1.UserName == Request.Cookies["MyCookie"]["username"])
                      //{
                      HttpCookie cookie = Request.Cookies.Get("MyCookie");
                      TextBox pass = (TextBox)Login1.FindControl("Password");
                      pass.Attributes.Add("value", Request.Cookies["MyCookie"]["password"]);
                      Login1.UserName = Request.Cookies["MyCookie"]["username"];
                      //}
                  }
              }

I have entered my user name and password and checked remember me ==true, So I created cookies to save username and password. saved but not remembered password when i enter user name and I used login controls to create username and password



//Required
I need to display password automatically in password textbox if username entered..........

Please It's very Important to me reply me soon
Posted
Updated 22-Dec-11 22:28pm
v2
Comments
Wendelius 23-Dec-11 4:28am    
Pre tags corrected. Subject line shortened.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900