Back

getSession("current") doesn't work serverside

  • 0
  • Accounts
kstulgys
23 Jun, 2023, 07:46
  • I login user with google auth,
  • create and send jwt to the server
  • setJwt on appwrite client (client....setJwt(jwt))
  • calling account.getSession("current") says user_session_not_found
TL;DR
The user is asking about an issue with the `getSession("current")` function not working serverside. Another user suggests using `getAccount()` instead. It is also mentioned that `getAccount()` is faster than `getSession()`. There is speculation that there may be a bug in the get session API. One solution is to set the JWT and session ID in a browser cookie and send it to the server on every request. No definitive answer or solution is provided in the thread.
kstulgys
23 Jun, 2023, 07:47

Why?

kstulgys
23 Jun, 2023, 07:53

my current solution is to set jwt and session_id in a browser cookie and send it over to the server on every request to perform actions

kstulgys
23 Jun, 2023, 07:53

is this is ok?

Binyamin
23 Jun, 2023, 13:42

Yep, this is a one valid way to do so.

Drake
23 Jun, 2023, 18:06

it might be good to create a github issue for this. I think there's a slight bug in the get session api when dealing with JWT tokens.

Drake
23 Jun, 2023, 18:08

this is interesting...i've been exploring this approach as away to deal with SSR πŸ‘€

On the server side, you should use the getAccount() rather than getSession("current") to validate the JWT works. getAccount() is faster than getSession() too

kstulgys
24 Jun, 2023, 07:34

@Steven There is no such suggestion from typescript (or in documentation) as getAccount

safwan
24 Jun, 2023, 07:38

getAccount(account.get) is an appwrite endpoint. Look here: https://appwrite.io/docs/server/account?sdk=nodejs-default#accountGet

safwan
24 Jun, 2023, 07:38

The endpoint is available on the server and client side

safwan
24 Jun, 2023, 07:38

I've linked the server-side docs though, just saying lol

Drake
24 Jun, 2023, 15:00

Sorry, it's account.get().

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