Skip to content
Orvanov0.2.0

Manage sessions

Each sign in opens its own session, so a user signed in on a laptop and a phone has two. Let users see them and end the ones they don’t recognize. Users and sessions explains what a session is.

account.listSessions answers with the user’s active sessions, newest first, a page at a time. listSessionsAll walks every page for you.

for await (const session of orvano.account.listSessionsAll()) {
console.log(session.userAgent, session.lastRefreshedAt, session.current)
}

Each session has:

Field What it holds
id The session’s ID.
current True for the session making this call: label it “This device”.
method How it started: password, sign_up, magic_link, email_code, or recovery.
createdAt, lastRefreshedAt When it started, and was last used.
userAgent, ipAddress The device it started on. For a Next.js app, the user’s browser, not your server.
sdk The SDK and version that started it.
await orvano.account.deleteSession(sessionId) // one session
await orvano.account.deleteOtherSessions() // every session but this one
await orvano.account.deleteCurrentSession() // sign out here

account.deleteSession ends one session, account.deleteOtherSessions every one but the current. An ended session’s device is signed out at its next refresh. Its last access token keeps working with your own servers for up to 15 minutes, unless they use the online check.

With an API key, your support tools can do the same for any user: users.listSessions (users.read), users.deleteSession and users.deleteSessions (users.write). To sign a user out everywhere and keep them out, block them.