Keep Me Logged In
Hi, I want to implement "Keep me Logged In" feature in my web site while Login. Please share some Idea..
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaganathan BantheswaranPosted Nov 11, 2013, 3:55 AM
On login click,
string username = txtUsername.Text;
string Password = txtPassword.Text;
// Create Cookie and Store the Login Detail in it if check box is checked
if ((keeeMeLoggedIn.Checked == true)) {
HttpCookie mycookie = new HttpCookie("LoginDetail");
mycookie.Values("Username") = txtUsername.Text.Trim();
mycookie.Values("Password") = txtPassword.Text.Trim();
mycookie.Expires = System.DateTime.Now.AddDays(365);
Response.Cookies.Add(mycookie);
}
Response.Redirect("Home.aspx");
On page load,
//check if cookie exist then login page from
if ((Response.Cookies("LoginDetail") != null)) {
//do stuff
}
else
{
//redirect to login page
}