Hi, just a question about sessions in react native...
# support-questions-legacy
b
Hi, just a question about sessions in react native, should .signout() method delete the session ? Because it is not the case on my implementation and it is a bit of a problem as I am use .doesSessionExist() to determine if the user is signedIn or not
r
hey @binouse yes it should delete the session. @nkshah2 can help here.
n
Hi, Just so I understand the situation, you are saying
doesSessionExist
returns true after you call
SuperTokens.signOut
?
b
Absolutely
n
Can I see the code for calling signOut?
b
Copy code
javascript
  useSignOut: (): (() => Promise<void>) => {
    const auth = useAuth();
    const client = useApolloClient();

    return async () => {
      await client.clearStore();
      try {
        await Supertokens.signOut();
      } catch (error) {
        console.log("supertokens signOut error: ", error);
      }
      await AsyncStorageHelper.writeString(keys.authToken, "");
      await AsyncStorageHelper.removeData("onboarding");
      auth.setIsSignedIn(false);
    };
  },
n
Are you using fetch when signing in?
or axios
b
Yes fetch
n
Can I see the code for where you use
useSignOut
b
Copy code
javascript
  const signOut = AuthUtils.useSignOut();

  const handleSignOut = async () => {
    if (deviceToken) {
      await deleteDeviceMutation({ variables: { token: deviceToken } });
    }

    await signOutMutation();
    await signOut();
    userLogOut();
  };
r
and when do you call doesSessionExist?
can you call it right after doing
await signOut();
- what does it print out there?
b
also true just after
await signOut();
r
hmm.
Can you print out the value of
await Supertokens.doesSesionExist()
after calling
await Supertokens.signOut();
inside the
useSignOut
?
b
LOG  Session after signout:  true
Copy code
javascript
      try {
        await Supertokens.signOut();
        console.log("Session after signout: ", await Supertokens.doesSessionExist());
      } catch (error) {
        console.log("supertokens signOut error: ", error);
      }
n
Can you reinstall the app and see if the issue still persistent (Not re-run it, uninstall and the reinstall it) Actually before you try that, can you post the full response you get from the sign out API?
b
Ah, i reinstalled it and the doesSessionExist got true after my google sign in but stayed true at Supertokens.signOut()
How can i catch the response from my API ?
n
Might be easier to debug this on call, ill send you a link
b
I changed my token handling process and it is working like a charm now
Thanks a lot for your time and your help
You guys are really amazing
n
Glad you got it working!
And yep, happy to help
r
For reference of anyone reading this in the future. The problem was that another token was being used for session management (other than supertokens session tokens) which was written to react native storage such that it replaced the cookies stored by supertokens.
This cause the sign out api to fail in session verification which makes it give a 200 reply, but it doesn’t clear cookies in this case.
Cause it didn’t clear access token cookies in this case, the other tokens (idRefreshToken) wasn’t cleared making doesSessionExist return true.
5 Views