简体   繁体   English

ABP Cookie过期时间问题

[英]ABP cookie expiration time issue

I'm using ABP v3.3.0. 我正在使用ABP v3.3.0。 In this version, I have some new experience. 在这个版本中,我有一些新的经验。 My application asks for login every 30 minutes, because my SignIn method takes in 30 minutes expiration time: 我的应用程序每30分钟要求登录一次,因为我的SignIn方法需要30分钟的到期时间:

_authenticationManager.SignIn(
    new AuthenticationProperties
    {
        IsPersistent = true,
        ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(int.Parse(System.Configuration.ConfigurationManager.AppSettings["AuthSession.ExpireTimeInMinutes.WhenNotPersistent"] ?? "30"))
    },
    identity);

In my Startup class, I found this code: 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),

But in AccountController , there is no property named IsPermanent . 但是在AccountController ,没有名为IsPermanent属性。 AuthenticationProperties is an object that has a property named IsPersistent . AuthenticationProperties是具有名为IsPersistent的属性的对象。

I guess it is a spelling mistake. 我猜这是一个拼写错误。 If not, please help me to find IsPermanent property on login. 如果没有,请帮助我在登录时查找IsPermanent属性。

ABP uses Microsoft.AspNetCore.Http.Authentication 's AuthenticationManager.SignInAsync method and AuthenticationProperties.IsPersistent property. ABP使用Microsoft.AspNetCore.Http.AuthenticationAuthenticationManager.SignInAsync方法和AuthenticationProperties.IsPersistent属性。

It works with the "Remember Me" checkbox on the login page. 它与登录页面上的“记住我”复选框一起使用。

See this explanation : 请参阅以下说明

Persistent cookies will be saved as files in the browser folders until they either expire or manually deleted. 永久性cookie将被保存为浏览器文件夹中的文件,直到它们过期或被手动删除。 This will cause the cookie to persist even if you close the browser. 即使关闭浏览器,这也将导致cookie保留。

If IsPersistent is set to false, the browser will acquire session cookie which gets cleared when the browser is closed. 如果IsPersistent设置为false,则浏览器将获取会话cookie,该会话cookie将在关闭浏览器时清除。

Now the reason session cookie wont clear after restarting the browser is because of chrome default settings. 现在,重新启动浏览器后无法清除会话Cookie的原因是Chrome默认设置。 To fix it go to chrome settings -> advanced, and uncheck Continue running background apps when Google Chrome is closed under System section. 要解决此问题,请转到Chrome设置->高级,然后取消选中“系统”部分下的“关闭Google Chrome浏览器后继续运行后台应用程序”。

Yes, it is a spelling mistake. 是的,这是拼写错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM