简体   繁体   中英

ABP cookie expiration time issue

I'm using 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:

_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:

// 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 . AuthenticationProperties is an object that has a property named IsPersistent .

I guess it is a spelling mistake. If not, please help me to find IsPermanent property on login.

ABP uses Microsoft.AspNetCore.Http.Authentication 's AuthenticationManager.SignInAsync method and AuthenticationProperties.IsPersistent property.

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. This will cause the cookie to persist even if you close the browser.

If IsPersistent is set to false, the browser will acquire session cookie which gets cleared when the browser is closed.

Now the reason session cookie wont clear after restarting the browser is because of chrome default settings. To fix it go to chrome settings -> advanced, and uncheck Continue running background apps when Google Chrome is closed under System section.

Yes, it is a spelling mistake.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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