title: ASP.NET Core 3.0 ConfigureApplicationCookie outside of ConfigureServices
body: <p>When setting the cookie ExpireTimespan in ConfigureServices it works perfectly. However, I would like to get the timespan from the database so I thought I would move it to Configure. I can read the value of <code>IOptions&lt;CookieAuthenticationOptions&gt;</code> just fine and I can set it but it does not appear to work.</p>
  <p>So this will work:</p>
  <pre><code>services.ConfigureApplicationCookie(options =&gt;
  {
      // Cookie settings
      options.Cookie.HttpOnly = true;
      options.ExpireTimeSpan = TimeSpan.FromMinutes(30);
  
      options.LoginPath = &quot;/Identity/Account/Login&quot;;
      options.AccessDeniedPath = &quot;/Identity/Account/AccessDenied&quot;;
      options.SlidingExpiration = true;
  });
  </code></pre>
  <p>But this doesn't. The value gets set but the cookie won't expire:</p>
  <pre><code>public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext db, IOptions&lt;CookieAuthenticationOptions&gt; options)
  {
      var settings = db.Settings.First();
      if (settings.ExpireTimeSpan != TimeSpan.Zero)
      {
          cookieoptions.Value.ExpireTimeSpan = settings.ExpireTimeSpan;
      }
  </code></pre>
  <p>What am I doing wrong? Does <code>IOptions&lt;CookieAuthenticationOptions&gt; options</code> need to be applied in some way? I tried it at the start and the end of the method.</p>