.net core(blazor) 中的登录过期会话问题

问题描述 投票:0回答:0

当我登录并将过期时间设置为 12 小时时,我会在 20 或 30 分钟后注销并重定向到登录页面。我不知道这是为什么。 这是我的代码

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

我想在 12 小时后注销,但我在 20 分钟后注销了

.net blazor logout expired-sessions expired-cookies
© www.soinside.com 2019 - 2024. All rights reserved.