ABP cookie到期时间问题

时间:2018-05-06 11:22:34

标签: c# authentication cookies asp.net-identity aspnetboilerplate

我正在使用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财产。

1 个答案:

答案 0 :(得分:2)

ABP使用 Microsoft.AspNetCore.Http.Authentication AuthenticationManager.SignInAsync方法和AuthenticationProperties.IsPersistent属性。

它适用于"记住我"登录页面上的复选框。

请参阅this explanation

  

永久性Cookie将作为文件保存在浏览器文件夹中,直到它们过期或手动删除。即使您关闭浏览器,这也会导致cookie保持不变。

     

如果IsPersistent设置为false,浏览器将获取会话cookie,当浏览器关闭时会被清除。

     

现在重启浏览器后会话cookie不会清除的原因是Chrome默认设置。要修复它,请转到chrome设置 - >高级,取消选中在系统部分下关闭Google Chrome时继续运行后台应用。

是的,这是拼写错误。