How to create persistent Cookie from HttpContext's Cookie.Append method?
Mahesh Kumar
65
Reputation points
var token = await _jwtTokenService.GenerateToken(user);
HttpContext.Response.Cookies.Append("accessToken", token, new CookieOptions
{
HttpOnly = true,
Expires = DateTime.UtcNow.AddHours(1),
SameSite = SameSiteMode.None,
Secure = false,
IsEssential = true,
});
I am attaching the token in Cookie with the help of HttpContext
I can't find a way to make it persistent . Right now, on refreshing the page, the cookie is destroyed automatically. I want it to stay in the browser ever after closing the page until its expiry date. How do i do it?
Sign in to answer