Back

Checking if User Session Exists

  • 0
  • Auth
  • Web
  • Cloud
Chris Nowicki
22 May, 2024, 20:25

What is the best way to check if a user session exists? We are using the Web SDK and using either account.get() or account.getSession('current')

however, when a user isn't logged in we get a 401 response which throws an error in the console.

is there a better way to be checking for user session?

TL;DR
Developers are asking for a way to check if a user session exists without getting a 401 response error in the console. The best method suggested is to use `account.get()` - if it executes successfully, the user is logged in; otherwise, check the error.
Steven
22 May, 2024, 20:50

account.get() is the best way. if it executes successfully, they are logged in. Otherwise, check the error

Chris Nowicki
22 May, 2024, 20:55

Hey Steven! Thanks for the quick response. Will the error show in the console of the browser in production?

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