我正在使用ABP v3.3.0。在这个版本中,我有一些新的经验。我的应用程序要求每30分钟登录一次,因为我的SignIn
方法需要30分钟的到期时间:
_authenticationManager.SignIn(
new AuthenticationProperties
{
IsPersistent = true,
ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(int.Parse(System.Configuration.ConfigurationManager.AppSettings["AuthSession.ExpireTimeInMinutes.WhenNotPersistent"] ?? "30"))
},
identity);
在我的Startup
课程中,我找到了这段代码:
// by setting following values, the auth cookie will expire after the
// configured amount of time (default 14 days) when user set the
// (IsPermanent == true) on the login
ExpireTimeSpan = new TimeSpan(int.Parse(ConfigurationManager.AppSettings["AuthSession.ExpireTimeInDays.WhenPersistent"] ?? "14"), 0, 0, 0),
但是在AccountController
中,没有名为IsPermanent
的属性。 AuthenticationProperties
是一个具有名为IsPersistent
的属性的对象。
我猜这是拼写错误。如果没有,请帮我在登录时找到IsPermanent
财产。
答案 0 :(得分:2)
ABP使用 Microsoft.AspNetCore.Http.Authentication 的AuthenticationManager.SignInAsync方法和AuthenticationProperties.IsPersistent属性。
它适用于"记住我"登录页面上的复选框。
请参阅this explanation:
永久性Cookie将作为文件保存在浏览器文件夹中,直到它们过期或手动删除。即使您关闭浏览器,这也会导致cookie保持不变。
如果IsPersistent设置为false,浏览器将获取会话cookie,当浏览器关闭时会被清除。
现在重启浏览器后会话cookie不会清除的原因是Chrome默认设置。要修复它,请转到chrome设置 - >高级,取消选中在系统部分下关闭Google Chrome时继续运行后台应用。
是的,这是拼写错误。