title: ASP.NET Core MVC Session Cookie Expiry
body: <p>I recently deployed my asp.net core mvc web app (.NET 4.6.1) to a shared hosting server. The following is what I used to set the session cookie parameters:</p>
  
  <pre><code>        services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;(config =&gt;
          {
              config.Cookies.ApplicationCookie.LoginPath = "/login";
              config.Cookies.ApplicationCookie.CookieName = "MyCookie";
              config.Cookies.ApplicationCookie.ExpireTimeSpan = TimeSpan.FromHours(1.0);
              config.Cookies.ApplicationCookie.SlidingExpiration = true;
          }
  </code></pre>
  
  <p>However, I notice that:</p>
  
  <p><s>1) When opening chrome developer tools, the 'Expires/Max Age' column shows "Session" for my auth cookie compared to the actual timeout value (which I set to be 1 hour).</s></p>
  
  <p>2) After a few minutes, I get logged off on my hosted website automatically (even though session is set to expire for 1 hour). - <strong>This problem still exists</strong></p>
  
  <p>Can you please let me know what I am doing wrong, or if I am missing anything?</p>
  
  <p>EDIT:</p>
  
  <p>I also have another session but that's just used to keep lightweight data about the client.</p>
  
  <pre><code>        services.AddMemoryCache();
  
          services.AddSession(options =&gt; {
              options.CookieName = "myOtherCookie";
              options.IdleTimeout = TimeSpan.FromDays(1.0);
          });
  </code></pre>
  
  <p>My sign-in code:</p>
  
  <pre><code>var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, true, lockoutOnFailure: true);
  </code></pre>
  
  <p>Snippet of my Configure Method:</p>
  
  <pre><code>    app.UseStaticFiles();
  
      app.UseIdentity();
  
      app.UseSession();
  
      app.UseMvc(
          routes =&gt;
          {
              routes.MapRoute(
                  name: "default",
                  template: "{controller=Home}/{action=Index}/{id?}");
          }
      );
  </code></pre>
  
  <p>Many thanks</p>
  
  <p>Terry</p>