I login to the program using the following code:
var ctx = await dbFactory.CreateDbContextAsync();var entForUpdate = ctx.Personels.FirstOrDefault(q => q.Email== model.Email);if (entForUpdate != null) { Claim rolClaime = default; Claim Fullname = default; if (entForUpdate.IDRole == 3) { rolClaime = new Claim(ClaimTypes.Role, "RoleUser"); } Fullname = new Claim("User", entForUpdate.Email.ToString()); ClaimsIdentity claimsIdentity = new ClaimsIdentity(new[] { rolClaime, Fullname }, "CookieUser"); ClaimsPrincipal User = new ClaimsPrincipal(claimsIdentity); if (entForUpdate.IDRole == 3) { HttpContext.Response.Redirect("/Showuser"); } }The top part works fine.
But
Now to logout the program
No matter how hard I try, I can't delete the saved cookie.
private async Task DeleteCookie(){ await JSRuntime.InvokeVoidAsync("deleteCookie"); NavigationManager.NavigateTo("/", true); `your text`}js
function deleteCookie() { res.cookie("CookieUser", "", { expires: new Date(0), path: '/' }); //or====== document.cookie = CookieUser +'=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';}