KratosMafia
KratosMafia

Reputation: 333

.net core 2.2 Session logout

So I have a problem with my session logout. After 20 minutes I get redirected to the home page of my website.

I've looked at Session Services but they all show ways to use the session timeout to make it so a label name or id just goes away after the set time. How do I change the Session timeout from default to any other time. I've added

services.AddSession(opts =>
{
   opts.IdleTimeout = TimeSpan.FromSeconds(10);
});

to my Startup.cs folder and added app.UseSession() to the Configure but the timeout doesn't time me out in 10 seconds. I know inside asp.net there is a web.config file that you can set the timeout time in my .net core doesn't have a web.config.

Upvotes: 1

Views: 812

Answers (1)

Joe Cullinan
Joe Cullinan

Reputation: 562

GDPR (no, seriously).

Core 2.1 introduced some tooling that assists with GDPR compliance by not storing non-essential cookies until a user consents to cookie storage. Unfortunately session state uses cookies, and since session state is used for all sorts of things, MS defaulted session state cookies to non-essential.

The easiest way to fix this is to implement the cookie consent form and accept it, but there are other workarounds that can be found here.

Upvotes: 1

Related Questions