'Update authentication Cookie in ASP.net CORE 3

In ASP.net CORE 3 app, I use authentication cookie without Identity. Here is the code when a user log in.

string securityStamp = Guid.NewGuid().ToString();
var userClaims = new List<Claim>()
{
  new Claim("id", id_user.ToString()),
  new Claim("securityStamp", securityStamp),
}                       
var grantMyIdentity = new ClaimsIdentity(userClaims, "User Identity");
var userPrincipal = new ClaimsPrincipal(new[] { grantMyIdentity });
await HttpContext.SignInAsync(userPrincipal);

At some point, I would like to update the securityStamp of the cookie without making the user log out and log in again. How can I do this transparently for the user?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source