© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago
Pesqoo

ASP .NET Session Auth

Hey guys,
I do currently have an ASP WebAPI using Cookie Auth with
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
    .AddCookie(options =>
// ...
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
    .AddCookie(options =>
// ...

This is not using sessions right? Since I can copy the cookie value, then call the logout endpoint which calls SignOutAsync, add the cookie again and still be authenticated.

But I want to use sessions, how can i make it that the frontend gets one cookie which stores the sessionId and is then authenticated with that sessionId?
I have read about .AddSession but I am confused, do I still need .AddAuthentication(...).AddCookie then? I didn't find anything related to auth with a session cookie, just ressources about either cookie auth or just sessions.

I do not want to use Identity since the User table already exists and my frontend is a separate react app.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ ASP.NET session timeout early
C#CC# / help
3y ago
ASP.NET Core auth + roles
C#CC# / help
3mo ago
❔ ASP.net Azure Authentication
C#CC# / help
3y ago
❔ Passwordless Authentication? (ASP.NET)
C#CC# / help
3y ago