Skip to main content

Sessions

Sessions provide time-limited authorization for SDK operations without requiring repeated signatures.

What is a Session?

A session is an authorization token that allows the SDK to execute transactions on behalf of the user for a limited time.

Session Properties

Session Scopes

Sessions have different permission levels:

Scope Permissions

The SDK uses DEFI scope by default.

Session Lifecycle

1. Creation

Sessions are created during setup():

2. Usage

The SDK automatically uses the session for subsequent operations:

3. Expiration

Sessions expire after the configured validity period:

4. Renewal

Create a new session by calling setup() again:

Checking Session Status

Via User Status

Manual Check

Session Configuration

Validity Duration

Minimum Duration

Sessions must be at least 60 seconds:

Session Flow Diagram

Clearing Sessions

Clear Current Session

This clears:
  • Active session
  • Cached signatures
  • User status
  • Stops workflow tracking

When to Clear

  • User logs out
  • User disconnects wallet
  • Security concern
  • Switching accounts

Session Errors

Expired Session

No Active Session

Best Practices

1. Check Session Before Operations

2. Handle Session Expiry Gracefully

3. Clear on Disconnect

4. Appropriate Validity Duration

Choose based on your use case:
  • Web app - 24 hours to 3 days
  • Mobile app - 7 days
  • Script/automation - 1 hour