Skip to main content
Para provides a comprehensive set of methods for managing authentication sessions in Flutter applications. These sessions are crucial for secure transaction signing and other authenticated operations.

Session Duration

Para session length is configured per API key and can be set up to 30 days through the Configuration section of the or CLI. The Para API enforces the configured duration. Signing a message or transaction, or calling the session keep-alive method, can extend an active session according to that configuration.

Managing Sessions

Automatic Persistence and Restore

The SDK saves the session to the device’s secure storage when a user signs in with the authenticate methods or a passkey, and restores it when you create Para, so a returning user stays signed in across app launches. If no saved session can be restored but the bridge still holds a live session, the SDK keeps that session instead of sending the user back to sign-in. A saved session from a different environment is discarded. logout() clears the saved session. Watch sessionStatus to know when the restore has finished:
Don’t call logout() while sessionStatus is SessionStatus.restoring. It can clear the saved session before the SDK restores it, signing the user out.

Checking Session Status

Use isSessionActive() to verify whether a user’s session is currently valid before performing authenticated operations, for example when your app returns to the foreground.
ParaFuture is a Future, so await it directly:

Extending Sessions

Call keepSessionAlive() to extend an active session. It returns false when the session has already expired.

Refreshing Expired Sessions

When a session has expired, Para recommends initiating a full authentication flow rather than trying to refresh the session.
Call logout() before reinitiating authentication when a session has expired. The authenticate methods throw already_authenticated while a session is still signed in.

Exporting Sessions to Your Server

Use exportSession() when you need to transfer session state to your server for performing operations on behalf of the user.
Example implementation:

Best Practices for Flutter

  1. Let the SDK restore sessions on launch: Build your first screen from sessionStatus (above) instead of checking the session yourself at startup.
  2. Handle App Lifecycle Changes: Flutter apps can be backgrounded and foregrounded, which may affect session status.

Next Steps

Explore more advanced features and integrations with Para in Flutter: