How to delete JWT cookie
Answered
Californian posted this in #help-forum
CalifornianOP
I am deleting a user account. What is the correct way to go about deleting the user's session/JWT http cookie.
Answered by riský
if you delete from cookie, the user doesn't have it anymore to use... but the token will still be valid
11 Replies
if you delete it from user's cookie, that is all you can do with jwt
as it is a stateless method, so it doesn't need any storage in the db, you can't really delete it
so, as long as you have the expiry time not too long, you have done all that you can do
because you don't want to store invalidated tokens (as loss of benifit if need to check that list first)
@riský if you delete it from user's cookie, that is all you can do with jwt
CalifornianOP
"if you delete it from user's cookie, that is all you can do with jwt"
1) But how can I do this?
2) If i delete the JWT from cookie will the session still be valid? What is the process here
Thanks for the help btw
1) But how can I do this?
2) If i delete the JWT from cookie will the session still be valid? What is the process here
Thanks for the help btw
if you delete from cookie, the user doesn't have it anymore to use... but the token will still be valid
Answer
CalifornianOP
So how do you invalidate the token, because even if you delete cookie the jwt is still valid?
the only way is to not use jwt... but it simplifies things lots, so do you really need that?
CalifornianOP
There should be a way for NextJS to auto expire the token
Maybe the signout function from next auth
If you look at how jwts work, you will see how that is impossible