Click here to Skip to main content
15,885,890 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Plz help me to find out the Concept of Remember me check box in login page.
I want to know how the value stored in a cookie and how to retrieve it from cookie and how to use the value ..
Posted

1 solution

C#
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Cookies["myCookie"] != null)
                {
                    HttpCookie cookie = Request.Cookies.Get("myCookie");
                    txtUserName.Text = cookie.Values["username"];
                    txtPassword.Attributes.Add("value", cookie.Values["password"]);



                }
            }

        }
 protected void btnLogin_Click(object sender, EventArgs e)
        {
 bool IsRemember = chkRememberMe.Checked;
                    if (IsRemember)
                    {
                        myCookie.Values.Add("username", txtUserName.Text);
                        myCookie.Values.Add("password", txtPassword.Text);
                        myCookie.Expires = DateTime.Now.AddDays(15);
                    }
                    else
                    {
                        myCookie.Values.Add("username", string.Empty);
                        myCookie.Values.Add("password", string.Empty);
                        myCookie.Expires = DateTime.Now.AddMinutes(5);
                    }
 Response.Cookies.Add(myCookie);
}
 
Share this answer
 

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