HttpCookie cok = new HttpCookie("SampleCookie"); cok.Expires.AddDays(1); cok.Values.Add("Username", txtUsername.Text); cok.Values.Add("Password", txtPassword.Text); Response.Cookies.Add(cok);
if (!Page.IsPostBack) { HttpCookie cookie = Request.Cookies["SampleCookie"]; if (cookie != null) { txtUsername.Text = cookie.Values["Username"]; //txtPassword.Text = cookie.Values["password"]; //This wont display the password in the password textbox txtPassword.Attributes.Add("Value", cookie.Values["password"]); //This will work } }