Skip to content
Init is coming / May 19 - 23
Back

deleteSession not working as expected

  • 0
  • Accounts
  • Web
QueenB
11 Jun, 2023, 15:35

I am trying to delete a user session when a login page renders, but I keep getting the sessionID is invalid, the documentation doesn't state exactly where I can get the sessionID from.

TL;DR
User is having trouble using the deleteSession function. They are not sure what argument to pass for the session ID. They are also questioning the use of deleting sessions when the login page renders. User is experiencing issues with the state of the current user after signing up. Solution: The session ID can be obtained from localStorage. It is not recommended to delete sessions when the login page renders.
Drake
11 Jun, 2023, 18:04

Why are you deleting a session when the login page renders?

What did you pass for the session ID?

QueenB
12 Jun, 2023, 09:07

sorry I meant when the sign up page renders, I realised that when I try to sign up a new user, and navigate to the dashboard of my application, it doesn't show the state of the current user who just signed up . So I am thinking it has to do with the session that stored in localStorage.

QueenB
12 Jun, 2023, 09:12

And I don't know exactly how to get the session ID

Guille
12 Jun, 2023, 13:14

Can you share your code?

Drake
12 Jun, 2023, 14:28

staying logged in is a feature so im not sure if it's a good idea to try and delete sessions when hitting the sign up page. A user shouldn't even see a sign up page if they already have a valid session since it wouldn't make sense.

After logging in, a user should be able to log out (account.deleteSession()) which would clear their cookie and the fallback cookie in local storage

QueenB
12 Jun, 2023, 21:35

Okay, I understand. But I am supposed to add the session ID as an argument in the deleteSession function. I'm not exactly sure what to use there.

Drake
12 Jun, 2023, 21:45

As the docs explain, you can use the string current to delete the current session

https://appwrite.io/docs/client/account?sdk=web-default#accountDeleteSession

QueenB
17 Jun, 2023, 23:39

Thank you so much, I will look at it.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more