Session Management
A comprehensive guide to managing sessions in Capsule, including both client-side and server-side approaches
Effective session management is crucial for maintaining security and providing a seamless user experience in applications using Capsule. This guide covers both client-side and server-side session management techniques.
Client-Side Session Management
Capsule uses sessions as a security measure when signing transactions. By default, a session is active for 90 minutes.
Checking Session Status
Before performing any action that requires an active session, such as signing a transaction, always check the session status:
Refreshing Sessions
Many SDK calls indicating user activity will automatically prolong the session. However, you can also extend the session programmatically:
keepAliveIsSuccessful
will be true
if the keep-alive call was successful, and false
otherwise.
Handling Session Timeouts
When a session times out, you’ll need to re-authenticate the user. Here’s an example of how to handle this in a transaction signing scenario:
Best Practices
-
Regular Checks: Implement regular session checks in your application, especially before critical operations.
-
Graceful Handling: Handle session expirations gracefully, providing a smooth re-authentication experience for users.
-
Security First: When implementing server-side session management, always use secure channels for transmitting session data.
-
Session Length: Consider your application’s security requirements when deciding on session length. You can customize this by contacting Capsule support.
Troubleshooting
If you encounter issues with session management:
- Ensure your Capsule SDK is up to date.
- Verify that your API key and environment settings are correct.
- Check your network connectivity, as session operations require communication with Capsule servers.
- If problems persist, review your logs and contact Capsule support with detailed information about the issue.
Was this page helpful?