How IsPersistent works in OWIN Cookie authentication

前端 未结 3 1087
后悔当初
后悔当初 2020-12-04 19:08

It seems I don\'t understand clearly how IsPersistent in OWIN cookie authentication works, the code below is to use IsPersistent:

v         


        
3条回答
  •  抹茶落季
    2020-12-04 20:04

    Persistent cookies for .Net Core 2.2 you might want to try this

    Example

    var claimsIdentity = new ClaimsIdentity(new[]
     { new Claim(ClaimTypes.Name, "test"),},CookieAuthenticationDefaults.AuthenticationScheme);
    
    HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), new AuthenticationProperties
    {
      IsPersistent = true,
      ExpiresUtc = DateTime.UtcNow.AddMinutes(30)
    });
    

提交回复
热议问题