protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { if (chk_rem.Checked) { HttpCookie mycookie1 = new HttpCookie("mycookie1"); //Response.Cookies.Remove("mycookie1"); Response.Cookies.Add(mycookie1); mycookie1.Values.Add("Username", txt_username.Text); mycookie1.Values.Add("Password", txt_password.Text); DateTime dtex = DateTime.Now.AddDays(15); if (chk_rem.Checked == true) { if (Request.Cookies["mycookie1"] != null) { HttpCookie getcookie1 = Request.Cookies.Get("mycookie1"); string un = getcookie1.Values["Username"].ToString(); string ps = getcookie1.Values["Password"].ToString(); } } } if (chk_rem.Checked == false) { Response.Cookies["mycookie1"].Expires = DateTime.Now.AddDays(-1); } } if (HttpContext.Current.Request.Cookies["mycookie1"] != null) { try { txt_username.Text = HttpContext.Current.Request.Cookies["mycookie1"]["Username"].ToString(); string a = HttpContext.Current.Request.Cookies["mycookie1"]["Password"].ToString(); txt_password.Attributes.Add("value", a); chk_rem.Checked = true; } catch { } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)