Imagine a user who leaves their laptop on a train. From their phone, they open your app's security settings looking for a way to sign that laptop out. If your app uses JWT access tokens and refresh tokens, there may be nothing to show them, because nothing on the server represents "the laptop." There are just tokens, and the server has never kept a list of them.
A sessions page fixes that, and building one forces you to answer a question most JWT setups skip: what exactly is a session?
A sessions and devices page comes down to a few decisions:
- Treat each login on each device as one session, represented by a refresh-token family with its own ID.
- Store sessions on the server, and show users a short, honest description of each.
- Let users revoke one session, or all sessions except the current one, after signing in again.
- Close the gap where access tokens keep working after revocation.
- Alert users when a new device signs in, and keep the stored data lean.
What is a session when you use JWTs?
With short-lived access tokens and refresh tokens, a user's sign-in on one device usually works like this: they log in, get an access token and a refresh token, and every so often trade the refresh token for a new pair.
The OAuth 2.0 Security Best Current Practice (RFC 9700) recommends refresh token rotation, where each refresh returns a new refresh token and the old one stops working. If an old refresh token is used again, the server treats it as a sign of theft and revokes the active one. Auth0's refresh token rotation guide gives the chain a name: a token family, meaning all refresh tokens descending from the original one issued at login.
That family is a natural definition of a session. It starts at login on a device, continues through every refresh, and ends when it's revoked or expires. Give it a stable identifier. OpenID Connect's Back-Channel Logout specification uses a sid claim for exactly this, describing a session of a user agent or device for a logged-in user. Putting a sid in your access tokens ties every request back to its session.
The sessions table
Store one row per session:
- Session ID (the
sid) and user ID. - The current refresh token's hash, never the raw token, so a database leak doesn't hand out working tokens.
- Created and last-used times.
- A device description captured at login: browser and operating system.
- Approximate location, if you show it.
- Revoked time and reason, such as "signed out," "signed out remotely," or "token reuse detected."
When a refresh comes in, look up the session by the token's hash, check it isn't revoked, rotate the token, and update the last-used time.
Reuse detection belongs on the sessions page
When a rotated refresh token is presented again, rotation says to revoke the session. Record why. A sessions page that shows "Signed out: suspicious token reuse" explains an unexpected logout far better than silence.
One caution: two browser tabs refreshing at the same moment can send the same refresh token twice, which looks like reuse. Tabs on one device share one session, so they should share one refresh, coordinated in the client. Some providers also allow a short overlap window; Auth0's rotation configuration calls it the Rotation Overlap Period. Keep any such window short.
What to show users
Show enough for a person to recognize their own devices, and no more:
- Device and browser, such as "Chrome on Windows." Browsers now send less detail. Chrome's User-Agent reduction freezes some values, for example reporting minor versions as zeros and Android versions generically, so parse the user agent at login and display something coarse rather than precise.
- Approximate location, at city or country level, if you show it at all.
- Last active, with care. Google's device activity help page notes that devices can appear active because of background communication, and that several devices can share a name. Your own "last used" time has the same limits, so phrase it as approximate.
- This device, clearly marked. GitLab's active sessions documentation notes that the current session can't be revoked from the list; users sign out of it normally instead.
GitHub's sessions settings are a good reference for a simple, readable list of web and mobile sessions with a revoke action.
Sign out one device
Revoking a session means marking its row revoked and refusing further refreshes from its token family. The next time that device tries to refresh, it fails and the user is signed out there.
The access-token gap
Revoking a session stops refreshes, not the access token the device already holds. RFC 7009, on token revocation, notes that when a server doesn't support revoking access tokens, they aren't immediately invalidated when the refresh token is revoked. Self-contained JWTs are the usual example: the API validates them without asking anyone, so a revoked laptop keeps working until its current access token expires.
OWASP's Application Security Verification Standard addresses this. Its session management requirements for version 5.0 say a terminated session must not be usable afterward, and list ways to achieve that with self-contained tokens: a list of terminated tokens, rejecting tokens issued before a per-user date and time, or rotating a per-user signing key.
In practice:
- Keep access tokens short, so the gap is minutes, not hours.
- Check the session ID on sensitive requests, comparing the
sidagainst a fast store of revoked sessions. Revoked entries only need to live as long as the longest access token. - Use a per-user "not before" time for "sign out everywhere," so any token issued earlier is rejected.
Sign out all other devices
"Sign out of all other sessions" should revoke every session for the user except the one making the request. Two rules from ASVS 5.0 shape it:
- Ask the user to authenticate again first. Requirement 7.5.2 says users should be able to view and terminate any or all active sessions after authenticating again with at least one factor. Someone who picked up an unlocked laptop shouldn't be able to sign the real owner out everywhere.
- Offer it after sensitive changes. Requirement 7.4.3 calls for giving users the option to terminate all other sessions after changing or removing any authentication factor, such as a password or a multi-factor method.
The OWASP Session Management Cheat Sheet recommends the same features: showing details of active sessions, alerting users about concurrent logins, and letting them terminate sessions remotely.
If you use Firebase, Auth0, or Entra
Identity providers handle sessions differently, so check what yours supports before designing the UI. As of November 2026:
- Firebase Authentication: the session management guide documents
revokeRefreshTokens, which revokes all of a user's refresh tokens at once. Existing ID tokens can stay valid until they expire, up to an hour, unless your backend checks revocation. A per-device list needs your own session records. - Auth0: its session management API can list and remove user sessions, on Enterprise plans. Deletion is processed asynchronously. Deleting a session and revoking it differ: the revoke endpoint also revokes the session's refresh tokens.
- Microsoft Entra ID: revokeSignInSessions invalidates all of a user's refresh tokens and session cookies, with a short delay of a few minutes. It's an all-or-nothing action.
If your provider only supports revoking everything, your sessions page can still list devices from your own records and offer "sign out everywhere," while being honest that single-device sign-out isn't available.
Real-time connections
A WebSocket or server-sent events connection opened before revocation stays open unless you close it. Track open connections by sid, and when a session is revoked, close its connections so the device has to reconnect and authenticate again.
New sign-in alerts
An email or in-app notice when a new device signs in lets users catch problems early. To keep it useful:
- Recognize known devices. A long-lived, random device identifier in a cookie lets you tell a returning device from a new one.
- Alert only on new devices, not every login, or users will learn to ignore the messages.
- Include what they need to act: device, approximate location, time, and a link straight to the sessions page.
NIST's digital identity guidelines (SP 800-63B) require notifying users about security events such as authenticators being added or accounts being recovered. They don't specifically require new-device alerts, but those notifications belong in the same system.
Privacy and retention
A sessions table is personal data about where and when someone used your app:
- IP addresses can be personal data. In the Breyer judgment (C-582/14), the EU Court of Justice held that a dynamic IP address can be personal data for a website operator in certain circumstances. Store a coarse location instead of the raw address where you can.
- Don't keep sessions forever. GDPR's storage limitation principle, in Article 5(1)(e) of the regulation, says data shouldn't be kept longer than necessary. Delete expired and revoked session rows after a set period, keeping only what your security audit needs.
Checklist
- Model each login on each device as a session backed by a refresh-token family with a
sid. - Store sessions server-side with hashed refresh tokens and a revocation reason.
- Revoke the session on refresh-token reuse, and coordinate refreshes across tabs.
- Show coarse device, location, and last-active details, and mark the current device.
- Revoke single sessions by refusing further refreshes.
- Close the access-token gap with short lifetimes,
sidchecks, or a per-user "not before" time. - Require re-authentication before signing out other sessions, and offer it after password or MFA changes.
- Check your identity provider's limits before designing the UI.
- Close real-time connections for revoked sessions.
- Alert on new devices, not every login, with a link to the sessions page.
- Store as little location data as you need, and purge old sessions.



