title: How to implement remember me in Login page in MVC 4 razor?
body: <p>I am creating Login page in MVC. I am trying to implement Remember me option in Login Page. I add the code for remember but it is not working properly. </p>
  
  <p>I have added the code with Response.cookies in login controller But it is not working.</p>
  
  <p>Where i need to implement that Request.cookies in this code</p>
  
  <p>Login Model</p>
  
  <pre><code>public class Login
      {
  
          public string EmailID { get; set; }
          public string Password { get; set; }
          public bool RememberMe { get; set; }
  }
  </code></pre>
  
  <p>Login controller</p>
  
  <pre><code> public ActionResult Login()
          {
  
              return View();
          }
  
  
  
   [HttpPost, ValidateInput(false)]
          public ActionResult Login(Login loginDetails)
          {
              if (ModelState.IsValid)
              {
                  using (SYTEntities context = new SYTEntities())
                  {
  
                      var LoginUser = context.tblUsers.Where(a =&gt; a.EmailID == loginDetails.EmailID &amp;&amp; a.Password == loginDetails.Password).FirstOrDefault();
                      if (LoginUser != null)
                      {  
                          FormsAuthentication.SetAuthCookie(loginDetails.EmailID, loginDetails.RememberMe);
                          Session["EmailID"] = LoginUser.EmailID;
                          Session["UserID"] = LoginUser.UserID;
   if (loginDetails.RememberMe)
                          {
                              HttpCookie email = new HttpCookie("EmailID");
                              email.Expires = DateTime.Now.AddSeconds(3600);
                              email.Value = LoginUser.EmailID;
                              Response.Cookies.Add(email);
  
                          }
                          return RedirectToAction("Index", "Home");
                      }
  
                      else
                      {
                          ModelState.AddModelError("", "Login data is incorrect!");
                      }
  
  
  
                  }
              }
              return View(loginDetails);
          }
  </code></pre>
  
  <p>Login.cshtml</p>
  
  <pre><code> @using (Html.BeginForm())
      {
          @Html.ValidationSummary(true, "Login failed. Check your login details.");
          &lt;div style=" margin-bottom: 400px;"&gt;
              &lt;fieldset&gt;
                  &lt;legend&gt;Login&lt;/legend&gt;
  
                  &lt;div class="editor-label"&gt;
                      @Html.LabelFor(u =&gt; u.EmailID)
                  &lt;/div&gt;
                  &lt;div class="editor-field"&gt;
                      @Html.TextBoxFor(u =&gt; u.EmailID)
                      @Html.ValidationMessageFor(u =&gt; u.EmailID)
                  &lt;/div&gt;
                  &lt;div class="editor-label"&gt;
                      @Html.LabelFor(u =&gt; u.Password)
                  &lt;/div&gt;
                  &lt;div class="editor-field"&gt;
                      @Html.PasswordFor(u =&gt; u.Password)
                      @Html.ValidationMessageFor(u =&gt; u.Password)
                  &lt;/div&gt;
                  &lt;div class="editor-label"&gt;
                          @Html.CheckBoxFor(u =&gt; u.RememberMe)
                          @Html.LabelFor(u =&gt; u.RememberMe)
                      &lt;/div&gt;
                  &lt;input type="submit" value="Log In" /&gt;
                  @Html.ActionLink("Forgot Password ?", "LostPassword", "CU", null)
              &lt;/fieldset&gt;
          &lt;/div&gt;
      }
  </code></pre>
  
  <p>Can any one tell me how to do this?</p>