Security

    Mobile session management: timeout, expiry, revocation

    A 2026 view of a mobile session lifecycle with short-lived access tokens, a rotating refresh token, idle and absolute timeouts, and server-side revocation on logout

    Session management is the lifecycle around a logged-in user: how the session is created, how long it lasts, when it ends, and how you can end it on demand. Mobile apps lean toward staying logged in for convenience, which makes the expiry and revocation parts easy to neglect, and a session that never really ends is a session a stolen token keeps alive. Good session management balances that convenience against the ability to expire and revoke access when it matters. Here is what session management should cover on mobile and how to handle timeouts, expiry, and revocation.

    Short answer

    Mobile session management is how you create, maintain, expire, and revoke a user's authenticated session, and doing it well means short-lived access tokens with refresh, idle and absolute timeouts, server-side revocation, and re-authentication for sensitive actions. Per OWASP, sessions should be able to end, on logout, on password change, or when a device is lost, which requires the server to invalidate them rather than the app merely deleting a local token. Store session tokens securely in the Keychain or Keystore, keep access tokens short and rotate refresh tokens, and treat the server as the authority over a session's validity, not the client.

    What you should know

    • Sessions need a lifecycle: creation, maintenance, expiry, and revocation.
    • Use short access tokens with refresh: limit the window of a stolen token.
    • Apply timeouts: idle and absolute, so sessions do not last forever.
    • Revocation must be server-side: logout and compromise must invalidate the session.
    • Re-authenticate for sensitive actions: step up for high-risk operations.

    What does good session management cover?

    The whole life of a session, not just logging in. Creating a session is the easy part; the parts that protect users are how long the session stays valid, what ends it, and your ability to end it deliberately. On mobile, the common pattern is a short-lived access token used for requests plus a longer-lived refresh token that obtains new access tokens, which keeps users logged in while limiting how long any single access token is useful. Around that, you need timeouts so a session does not live indefinitely, the ability to revoke a session on the server when the user logs out or their credentials change, and stronger checks before sensitive actions. The mistake is treating login as the whole job and leaving sessions effectively permanent, since a session that cannot be expired or revoked is one a stolen token can ride indefinitely.

    How should timeouts and expiry work?

    With both idle and absolute limits, balanced against usability. The table outlines the controls.

    ControlPurpose
    Short access-token expiryLimits how long a stolen access token is useful
    Refresh token with rotationKeeps the user logged in while limiting reuse
    Idle timeoutEnds a session after a period of inactivity
    Absolute timeoutCaps the total lifetime of a session
    Re-authentication for sensitive actionsRequires a fresh check before high-risk operations

    The combination matters. A short access-token expiry means a leaked access token expires quickly, while a refresh token, ideally rotated on each use so an old one cannot be reused, preserves the logged-in experience. An idle timeout ends sessions that are abandoned, and an absolute timeout ensures no session lives forever. For high-value apps you tune these tighter; for low-risk apps you can be more generous, but the session should still be able to expire.

    How do you handle revocation and re-authentication?

    Make the server the authority, and step up for sensitive actions. Revocation has to happen on the server: when a user logs out, changes their password, or reports a lost device, your backend must invalidate the session or token so it stops working, rather than relying on the app to delete a local copy, which a stolen token would not respect. That means tracking sessions or using a token design you can revoke, and offering a way to sign out other sessions. For sensitive operations, changing a password, making a payment, viewing especially sensitive data, require re-authentication or a fresh factor even within an active session, so a borrowed or briefly accessed device cannot perform them. And store the session and refresh tokens in the Keychain or Keystore so they are not extractable from plain storage. The throughline is that the client holds a session credential, but the server decides whether that session is still valid.

    What to watch out for

    The first trap is a session that never effectively expires, so a stolen token works indefinitely; use short access tokens, refresh rotation, and timeouts. The second is logout that only deletes the local token without server-side revocation, leaving the session valid; invalidate it on the server. The third is allowing sensitive actions within any active session without re-authentication. A pre-submission scan such as PTKD.com (https://ptkd.com) reads the compiled binary against OWASP MASVS and checks how session tokens are stored, which complements designing the lifecycle by confirming the tokens are kept securely. The expiry and revocation logic lives on your server.

    What to take away

    • Mobile session management covers creating, maintaining, expiring, and revoking a session, not just logging in.
    • Use short-lived access tokens with rotating refresh tokens, plus idle and absolute timeouts, so sessions do not last forever.
    • Revoke sessions on the server for logout, password change, or a lost device, and require re-authentication for sensitive actions.
    • Store session tokens in the Keychain or Keystore, and use a pre-submission scan such as PTKD.com to confirm they are stored securely.
    • #session-management
    • #tokens
    • #authentication
    • #session-timeout
    • #revocation
    • #owasp-masvs
    • #app-security

    Frequently asked questions

    What does mobile session management cover?
    The whole life of a session: creating it, maintaining it, expiring it, and revoking it, not just logging in. The parts that protect users are how long the session stays valid, what ends it, and your ability to end it deliberately. On mobile, the common pattern is a short-lived access token plus a longer-lived refresh token, surrounded by timeouts, server-side revocation, and stronger checks for sensitive actions. Treating login as the whole job leaves sessions effectively permanent, which is the mistake.
    How should session timeouts work?
    Use both an idle timeout, which ends a session after inactivity, and an absolute timeout, which caps the total lifetime so no session lasts forever, alongside short access-token expiry and a rotating refresh token. The short access token limits how long a leaked one is useful, the refresh token preserves the logged-in experience, and the timeouts ensure sessions end. Tune these tighter for high-value apps and more generously for low-risk ones, but a session should always be able to expire.
    Why must session revocation be server-side?
    Because a stolen token would not respect the app deleting its local copy. When a user logs out, changes their password, or reports a lost device, your backend must invalidate the session or token so it stops working, which means tracking sessions or using a revocable token design. If logout only clears the client, the session remains valid on the server and a copied token still works. The server is the authority over whether a session is still valid.
    When should I require re-authentication?
    Before sensitive operations, even within an active session: changing a password, making a payment, or viewing especially sensitive data. Requiring a fresh authentication or factor at those points means a borrowed or briefly accessed device cannot perform high-risk actions just because a session is open. This step-up is separate from the session staying logged in for ordinary use, and it limits the damage if a logged-in device is left unattended or accessed by someone else.
    How do I store session tokens securely on mobile?
    In the Keychain on iOS or the Keystore-backed secure storage on Android, not in UserDefaults, SharedPreferences, or other plain storage that can be read off the device, and transmit them only over HTTPS. The lifecycle, expiry, and revocation are server-side, but the tokens the app holds must be stored securely. A pre-submission scan such as PTKD.com checks how your app stores session tokens, complementing the server-side session design with confirmation that the client side is secure.

    Keep reading

    Scan your app in minutes

    Upload an APK, AAB, or IPA. PTKD returns an OWASP-aligned report with copy-paste fixes.

    Try PTKD free