Session Management
Learn how to use OTPless JavaScript SDK functions for session management, including verifying and revoking sessions.
1. Get Session
The OTPless JavaScript SDK provides the OTPlessVerifySession
method to retrieve the current session state. This method helps check whether the user is logged in and returns an in-memory session object if the session is active.
Usage
Behavior
a. If Logged In: Returns the in-memory session object containing details of the active session.
b. If Not Logged In: Returns an object with success: false
.
2. Revoke Session
The SDK provides a method to log out a user by revoking their current session. This wraps the OTPless Revoke Session endpoint.
Usage
Behavior
- Clears the user and session objects from local storage.
- If the SDK cannot contact the OTPless servers, it retains the local session state for recovery or retry.
When to Use
Call this method to log out a user securely and ensure their session is invalidated both locally and server-side.
Was this page helpful?