title: mvc 5 Set Cookie Expire, but expiration back to 01/01/0001
body: <p>I set cookie when login success like this :</p>
  
  <pre><code>public JsonResult LoginWithPassword(String password)
          {
  
                  Response.Cookies.Remove("Auth");
                  string CookieName = "Auth";
                  long UserId = 4;
  
                  HttpCookie myCookie = HttpContext.Response.Cookies[CookieName] ?? new HttpCookie(CookieName);
                  myCookie.Values["UserId"] = UserId.ToString();
                  myCookie.Values["LastVisit"] = DateTime.Now.ToString();
                  myCookie.Expires = DateTime.Now.AddDays(1);
                  HttpContext.Response.Cookies.Add(myCookie);
  
                  return Json(new { IsSuccess = true, ReturnUrl = returnUrl });
              }
              else
              {
                  return Json(new { IsSuccess = false, Message = "Login fail, Wrong Password" });
              }
          }
  </code></pre>
  
  <p>and i read it in next page/action :</p>
  
  <pre><code>public ActionResult Index()
          {
              if (HttpContext.Request.Cookies["Auth"] == null)
                  return RedirectToAction("Login", "Access");
              return View();
          }
  </code></pre>
  
  <p>Really strange the cookie of "Auth" always empty. When i check the expiration date in debugging breakpoint, i get expiration date : <code>01/01/0001</code>.</p>
  
  <p>why this happend and how to solve this?
  This action in two differents controller</p>