Keep Me Logged In
Hi, I want to implement "Keep me Logged In" feature in my web site while Login. Please share some Idea..
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Nov 10, 2013, 10:55 PM EST
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
}