Back

logging in via session

  • 0
  • Self Hosted
  • Flutter
mauricev
14 Feb, 2023, 06:10

When restarting my app, is there a way I can have the user log back in using the session object, so the user doesn’t have to re-enter their credentials?

TL;DR
The SDK automatically persists sessions, so the user is already authenticated when they return to the app. On app start, you can call `account.get()` to check if the user is authenticated. If it returns successfully, you can redirect them into the app. If an exception is thrown, redirect them to the login page. Thus, there is no need for the user to re-enter their credentials.
Drake
14 Feb, 2023, 06:38

Since the SDK automatically persists sessions, the user is already authenticated the next time they come back to your app.

The typical pattern is to do the following on app start:

  1. Call account.get() 2a. If that returns successfully, the user is already authenticated and you can redirect them into the app. 2b. If an exception is thrown, they don't have a session so redirect them to the login page
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