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
| Property | Type | Description |
|---|---|---|
sessionKeyAddress | string | Address of the session key |
validUntil | number | Unix timestamp of expiry |
scope | SessionScope | Permission level |
authorizationSignature | string | Authorization proof |
Session Scopes
Sessions have different permission levels:Scope Permissions
| Scope | Read Data | Borrow | Repay | Withdraw | Admin |
|---|---|---|---|---|---|
READ | ✓ | ✗ | ✗ | ✗ | ✗ |
DEFI | ✓ | ✓ | ✓ | ✓ | ✗ |
FULL | ✓ | ✓ | ✓ | ✓ | ✓ |
DEFI scope by default.
Session Lifecycle
1. Creation
Sessions are created duringsetup():
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 callingsetup() again:
Checking Session Status
Via User Status
Manual Check
Session Configuration
Validity Duration
| Duration | Seconds | Use Case |
|---|---|---|
| 1 hour | 3600 | High security |
| 24 hours | 86400 | Daily usage |
| 3 days | 259200 | Default, convenience |
| 7 days | 604800 | Infrequent usage |
Minimum Duration
Sessions must be at least 60 seconds:Session Flow Diagram
Clearing Sessions
Clear Current Session
- 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