title: Protecting endpoints using Session cookie ASP.NET Core
body: <p>Is there a native ASP.NET Core method for securing endpoints via a Session Cookie? I have successfully implemented a Session using a Cosmos backing store by following <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/app-state?view=aspnetcore-5.0" rel="nofollow noreferrer">the article on MSFT</a> but have yet to figure out how to translate that into securing my endpoints.</p>
  <p><a href="https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?view=aspnetcore-5.0" rel="nofollow noreferrer">Cookie authentication</a> seems like the way to go but I cannot figure out how to quite get it right.</p>
  <p>I feel like by using:</p>
  <pre><code>services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
      .AddCookie();
  </code></pre>
  <p>I am instead creating another cookie instead of reusing the one given to me by the Session middleware.</p>
  <p>Ultimately, I want to be able to only allow for specific endpoints to be called if the user has a session and it is a valid one. Thanks!</p>