Login Expire session issue in .net core(blazor)

378 Views Asked by At

When I log in and set expire time to 12 hours I get logged out after 20 or 30 minutes and redirect to the login page. I don't know the reason for that. This is my code

List<Claim> claims = new List<Claim>{
                new Claim(ClaimTypes.Email, user.Email),
                new Claim(ClaimTypes.Name, FullName),
                new Claim(ClaimTypes.Surname, user.Username),
                new Claim(ClaimTypes.UserData, "Active"),
                new Claim(ClaimTypes.Sid, user.UserId.ToString()),
            };
AuthenticationProperties authProperties = new AuthenticationProperties
            {
                IsPersistent = true,
                ExpiresUtc = DateTime.UtcNow.AddHours(12),
                AllowRefresh =true,
            };
ClaimsIdentity identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
ClaimsPrincipal cp = new ClaimsPrincipal(identity);
awaitHttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,cp,authProperties);

see the screen shoot cookie expire time set 12 hours in utc datetime

I am trying to log out after 12 hours but I get logged out after 20 minutes

0

There are 0 best solutions below