1

How I can update Cookie Expiration time when signin with below code

var result = await _signInManager.PasswordSignInAsync(userName, password, isPersistent, lockoutOnFailure);

Like can use with SingInAsyn

 var authProps = new AuthenticationProperties
 {
      IsPersistent = isPersistent,
      ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(5)
 };
 await _signInManager.SignInAsync(user, authProps, authenticationMethod);
David Liang
  • 20,385
  • 6
  • 44
  • 70
Ravi
  • 408
  • 7
  • 22
  • think this may help you, check the question and answer [ExpireTimeSpan ignored after regenerateIdentity / validateInterval duration in MVC Identity (2.0.1)](https://stackoverflow.com/q/23983726/9988501) – Flywings Mar 19 '20 at 14:02
  • Did the following answer resolve your issue?https://stackoverflow.com/a/59744231/11398810 – Rena Mar 20 '20 at 05:03
  • @Rena, no it doesn’t – Ravi Mar 20 '20 at 05:08

1 Answers1

2

Didn't found the way to pass authenticationProperties but below code works. Need to override the SignInWithClaimsAsync method of SingInManager class

public override async Task SignInWithClaimsAsync(ApplicationUser user, AuthenticationProperties authenticationProperties, System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> additionalClaims)
{
    if (authenticationProperties != null && authenticationProperties.IsPersistent)
    {
        authenticationProperties.ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(30);
    }

    await base.SignInWithClaimsAsync(user, authenticationProperties, additionalClaims);
}
Ravi
  • 408
  • 7
  • 22