0

In asp.net core, we want to change the logout processing time from 30 minutes to 1 day when the login expires.

Looking at the Startup.cs of the previously created project, it seemed that 'IdleTimeout' could be set.

So, I changed 'FromMinutes(30)' to 'FromDays(1)', but I am still logged out after 30 minutes of login.

I want to keep the login time at 1 day.

**For reference, since this is an administrator page, IP access is restricted.

Please let me know how the login expiration time can be applied to 1 day

//Before change

services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(30);
}

//After Change
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromDays(1);
}
Sujin
  • 11
  • 3

1 Answers1

0

As far as I know, we will store the authentication token inside the cookie instead of session normally. I guess this is the reason why your codes doesn't work well.

If you use cookie authentication, I suggest you could try below codes:

services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
     options.ExpireTimeSpan = TimeSpan.FromDays(1);
});
    }

If you used asp.net core identity, I suggest you could try below codes:

services.AddIdentity<ApplicationUser, IdentityRole>(options => {

    options.Cookies.ApplicationCookie.ExpireTimeSpan = TimeSpan.FromDays(1);

});

More details about how it works, I suggest you could refer to this answer.

Brando Zhang
  • 22,586
  • 6
  • 37
  • 65