title: Setting Session Timeout in ASP.net Core 3.1
body: <p>I have a web app .net core 3.1 razor pages. I have the session timeout set to 30 minutes, however it logs the current user out after 10 minutes of inactivity. The global IIS settings are set for 60 minutes on the server. Here is my code in Startup.cs. What am I missing? Any help is greatly appreciated. Thanks!</p>
  <pre><code>     public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
  
      public IConfiguration Configuration { get; }
  
  public void ConfigureServices(IServiceCollection services)
      {
          services.AddMvc();
          services.AddControllers().AddNewtonsoftJson(options =&gt;
           options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
          );
          services.AddSingleton&lt;IHttpContextAccessor, HttpContextAccessor&gt;();
          services.AddTransient&lt;IMemberService, MemberService&gt;();
          services.AddTransient&lt;INewsService, NewsService&gt;();
          services.AddTransient&lt;IUserCardService, UserCardService&gt;();
          services.AddTransient&lt;IUsernameService, UsernameService&gt;();
          services.AddTransient&lt;ILinkService, LinkService&gt;();
          services.AddTransient&lt;INotificationService, NotificationService&gt;();
  
          services.AddTransient&lt;IEmailSender, EmailSender&gt;();
          services.Configure&lt;AuthMessageSenderOptions&gt;(Configuration);
  
          services.AddDbContext&lt;DefaultContext&gt;(options =&gt;
           options.UseSqlServer(
           Configuration.GetConnectionString(&quot;DefaultContextConnection&quot;)));
  
          services.AddControllersWithViews()
                  .AddSessionStateTempDataProvider();
  
          services.Configure&lt;CookiePolicyOptions&gt;(options =&gt;
          {
              // This lambda determines whether user consent for non-essential
              // cookies is needed for a given request.
              options.CheckConsentNeeded = context =&gt; true;
              // requires using Microsoft.AspNetCore.Http;
              options.MinimumSameSitePolicy = SameSiteMode.None;
          });
  
          services.AddDistributedMemoryCache();
  
          services.AddSession(options =&gt;
          {
              options.IdleTimeout = TimeSpan.FromMinutes(30);
              options.Cookie.HttpOnly = true;
              options.Cookie.IsEssential = true;
              
          });
  
          services.AddRazorPages()
                  .AddRazorRuntimeCompilation()
                  .AddSessionStateTempDataProvider();
  
          services.AddSession();
      }
  
   public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
              app.UseBrowserLink();
              //app.UseDatabaseErrorPage();
          }
          else
          {
              app.UseExceptionHandler(&quot;/Error&quot;);
              app.UseHsts();
          }
  
          app.UseHttpsRedirection();
  
          app.UseRewriter();
  
          app.UseStaticFiles();
  
          app.UseCookiePolicy();
  
          app.UseRouting();
         
          app.UseAuthentication();
          app.UseAuthorization();
  
          app.UseSession();
  
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapRazorPages();
  
          });
  
  
  
      }
  </code></pre>