Skip to content
Back

Struggling with Sessions

  • 0
  • Auth
  • Web
  • Cloud
Red Dwarf
8 Jun, 2025, 01:21

Understanding check:

createAnonymousSession() registers the session with the backend

setSession() creates a cookie on the user’s computer(?)

getSession(‘current’) retrieves that cookie so that the user can pick up where they left off(?)

So I would call getSession(‘current’) on load, and if it fails I create and set a session so it doesn’t fail the next time the user visits. Is that correct?

TL;DR
Developers discussing issues with sessions and authentication for an app. One developer questioning how to handle sessions for anonymous users. Another developer clarifying that getSession only retrieves session data, not cookies. A solution proposed is to call getSession(‘current’) on load, and if it fails, create and set a session to prevent future failures.
Steven
8 Jun, 2025, 01:26

Are you using SSR?

Red Dwarf
8 Jun, 2025, 01:28

no

Steven
8 Jun, 2025, 01:29
Steven
8 Jun, 2025, 01:30

Set session is only used for SSR

Steven
8 Jun, 2025, 01:32

GetSession only gets the session data, not any cookie or anything like that.

Red Dwarf
8 Jun, 2025, 01:36

I believe I consulted that page, yes. I was unsure whether account.get() would work with anonymous users.

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