title: .net core 3.1 cookie authentication asking for login when leaving and coming back
body: <p>When I leave my .net core application to go to another page, upon return it asks me to login again.  I have already logged in before navigating away.  I'd think it would hold the cookie longer.  Here is all my authentication code.</p>
  
  <p>Startup.cs</p>
  
  <pre><code>services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options =&gt; {
              options.Cookie.HttpOnly = true;
              options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
              options.Cookie.SameSite = SameSiteMode.Lax;
              options.Cookie.Name = "xxx.Cookies";
          });
  
          services.Configure&lt;CookiePolicyOptions&gt;(options =&gt; {
              options.MinimumSameSitePolicy = SameSiteMode.Strict;
              options.HttpOnly = HttpOnlyPolicy.None;
              options.Secure = CookieSecurePolicy.Always;
          });
  
          services.ConfigureApplicationCookie(options =&gt; options.LoginPath = "/LogIn");
  
  services.AddMvc(options =&gt; options.Filters.Add(new AuthorizeFilter()));
  </code></pre>
  
  <p>Login</p>
  
  <pre><code>[HttpPost]
      [AllowAnonymous]
      public IActionResult Login(LoginViewModel model, string returnUrl)
      {
          bool isUservalid = false;
          User user = db.Users.Where(usr =&gt; usr.Email == model.Email).FirstOrDefault();
  
          var isPassword = _passwordManager.Verify(user.Password, model.Password);
  
          if (isPassword == PasswordVerificationResult.Success)
          {
              isUservalid = true;
          }
  
          if (ModelState.IsValid &amp;&amp; isUservalid)
          {
              var claims = new List&lt;Claim&gt;();
  
              claims.Add(new Claim(ClaimTypes.Email, user.Email));
              claims.Add(new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()));
  
              var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
  
              var principal = new ClaimsPrincipal(identity);
  
              var props = new AuthenticationProperties();
              props.IsPersistent = model.RememberMe;
  
              HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, props).Wait();
  
              return RedirectToAction("Index", "Dashboard");
          }
          else
          {
              ViewData["message"] = "Invalid UserName or Password!";
          }
  
          return View();
      }
  </code></pre>
  
  <p>I know the login is working because it lets me get to [Authorize] controllers.</p>