In my web application, there is a possibility for a user to delete a different user. But I noticed that after the user is deleted, the cookie still remains in the browser of the user, which enables them to navigate the website even though the user does not exist anymore. How do I make so that the cookie is invalid?
1 Answer
write this line of code after deleting the user:
_userManager.UpdateSecurityStamp(userId)
and it should works.
7 Comments
A. Savva
I used it before I delete the user, nothing changes, probably since no changes have been made to the user yet. I used it after I deleted the user and it can't find the
userId, since the user is deletedElyas Esna
are you using usermanager for deleting the user or db functions?
Elyas Esna
if you use this code for deleting the user it shouldn't be any problem:
_userManager.Delete(_userManager.Users.FirstOrDefault(p => p.Id == uderId));A. Savva
I'm using
UserManager, exactly the way you posted here. The user is deleted, but the cookie of the user remains there. How do I use UpdateSecurityStamp(userId) with it?Elyas Esna
|