Back

[SOLVED] Deleting sessions when changing password

  • 0
  • Users
  • Accounts
  • Web
Hexi
28 May, 2023, 09:19

Is it possible to delete all the sessions after changing password or is it needed to do it serverside with my own code?

TL;DR
User is looking for assistance on deleting previous user sessions when a login component is rendered. They are unsure of where to find the session ID. The solution is to use the Appwrite documentation provided by the user, specifically the section on deleting sessions using the API endpoint `/v1/account/sessions`. The user can fetch the sessions and delete them individually or delete them all, but this will also delete the current session. The user can decide whether to perform this action on the client or server side, depending on their needs.
Eldad
28 May, 2023, 09:21

You can just call the session deletes API and decide which sessions to delete or let your users decide

Hexi
28 May, 2023, 09:21

Ah alright but what would be better for production to put that on the client or server when your on the reset page

Hexi
28 May, 2023, 09:21

Thanks!

Eldad
28 May, 2023, 09:22

Your call, depends on how important it is

Eldad
28 May, 2023, 09:22

You can use the jwt to perform actions on behalf of your user inside a function

Hexi
28 May, 2023, 09:22

So fetch: /v1/account/sessions and then go through all the ids and delete it or is there a better way?

Eldad
28 May, 2023, 09:26

You can also delete all together, but this will also delete the current session

Hexi
28 May, 2023, 09:26

Yeah that wouldnt really matter

Hexi
28 May, 2023, 09:26

Thanks

Eldad
28 May, 2023, 09:26

Anytime 👍

Eldad
28 May, 2023, 09:27

Please mark issue as resolved 🙏

Hexi
28 May, 2023, 09:27

[SOLVED] Deleting sessions when changing password

Hexi
28 May, 2023, 09:27

made it my habbit to do that <a:happi:1107928866477064202>

Eldad
28 May, 2023, 09:27

<:appwritepeepo:902865250427215882>

Hexi
28 May, 2023, 09:27

<a:happi:1107928866477064202>

QueenB
11 Jun, 2023, 15:31

Hello, please I am trying to delete the previous userSession when a Login component is renders, but the documentation doesn't state where I can get the sessionID from. Please how can I do this?

Drake
11 Jun, 2023, 15:32

Please create a new <#1072905050399191082> post if you don't find a solution after searching

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