https://supertokens.com/ logo
b

Binouse

09/22/2022, 3:37 PM
Hi, How can I delete my user and remove its session from React Native ? I am deleting my user in my api and it's working perfectly but it is not removing my client session.
r

rp

09/22/2022, 3:38 PM
hey @Binouse
session verification happens in a stateless way in the backend, so when it refreshes, the session should be cleared on the frontend
b

Binouse

09/22/2022, 3:41 PM
I thought it was the case too but figured out that
doesSessionExist
still returns true even when user does not exists in db
r

rp

09/22/2022, 3:42 PM
yeaaa.. thats the disadvantage of using stateless session verification
but it's a smaller issue compared of the benefit of it
b

Binouse

09/22/2022, 3:42 PM
How can i remove my session then
r

rp

09/22/2022, 3:42 PM
also, in your code, when you detect this inconsistency, you can throw an unauthorised error on the bakcend which will result in clearing the cookies anyway
you can return a 401 to the frontend. That should trigger a session refresh, which will detect that the session doesn't exist -> log out the user
b

Binouse

09/22/2022, 3:47 PM
Okay, calling
Supertokens.signOut()
after deleting user refresh the session
Perfect, thanks ๐Ÿ˜Š
r

rp

09/22/2022, 3:47 PM
oh yea.. you can call that from the frontend, and it would work
b

Binouse

09/22/2022, 3:48 PM
Yep, itโ€™s easier
r

rp

09/22/2022, 3:48 PM
yup
5 Views