Join our Newsletter — 33% off our NHI Course
Home› Guides› Persistent Login and Session Timeout Guide: Remember-Me Tokens,…
Guide Authentication

Persistent Login and Session Timeout Guide: Remember-Me Tokens, Idle and Absolute Timeouts

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 14 min read
On this page

Sessions that never expire, remember-me cookies that act as a second password and logouts that only delete a cookie in the browser turn every stolen token into lasting account access. Getting session lifetime right means choosing an idle timeout and an absolute timeout per assurance level, enforcing both on the server, designing persistent login so a stolen or leaked token is limited and revocable, and asking users to prove themselves again before sensitive actions. This guide uses the timeout values in NIST SP 800-63B-4 (final, July 2025) and the session requirements in OWASP ASVS 5.0, and turns them into design choices. It is written for web developers, AppSec engineers and architects who own login and session code. For the attack side, see the Session Hijacking and Cookie Theft Guide.

Key takeaways

  • Two clocks, both server-side. Every session needs an inactivity timeout and an overall (absolute) timeout, and NIST SP 800-63B-4 says the session SHALL be terminated when either expires; cookie expiry SHALL NOT be relied on to enforce them.
  • NIST values changed in revision 4. Overall timeout SHOULD be no more than 30 days at AAL1 and 24 hours at AAL2, and SHALL be no more than 12 hours at AAL3; inactivity SHOULD be no more than 1 hour at AAL2 and 15 minutes at AAL3.
  • Remember-me is a reauthentication aid, not a login. NIST allows "remember my browser" style cookies only for AAL2 reauthentication after the inactivity limit but before the overall limit; they must never replace authentication.
  • Split, hash and rotate persistent tokens. A selector-validator token stores only a hash of the validator, compares in constant time, rotates on use and is revoked on password or MFA change.
  • Logout must kill the session at the backend. ASVS 5.0 V7.4.1 requires that terminated sessions cannot be used again, which for self-contained tokens means a deny list, a per-user cut-off time or key rotation.

Session lifetime basics

A session starts when an authentication event succeeds and the server issues a session secret, normally an opaque identifier in a cookie or a token held by a client. From then on the secret is a bearer credential: whoever holds it is treated as the user, at the assurance level of the original login. NIST SP 800-63B-4 states that a session SHOULD inherit the AAL properties of the authentication event that created it and SHALL NOT be considered higher than that. Three properties decide how much damage a leaked session can do: how long it lives, where it can be replayed from, and whether the server can kill it.

ElementRequirementSource
Session secret generationApproved random bit generator, at least 64 bitsNIST SP 800-63B-4 session section
Reference token entropyCSPRNG with at least 128 bits of entropyASVS 5.0 V7.2.3
New token at loginGenerate a new session token on authentication and re-authentication, terminate the old oneASVS 5.0 V7.2.4
VerificationAll session token verification by a trusted backend serviceASVS 5.0 V7.2.1
Cookie Secure flagSHALL be HTTPS onlyNIST SP 800-63B-4; ASVS 5.0 V3.3.1
Cookie HttpOnlySHOULD be inaccessible to JavaScript; ASVS requires it for session tokensNIST SP 800-63B-4; ASVS 5.0 V3.3.4
Cookie prefix and path__Host- prefix with Path=/ unless shared across hostsNIST SP 800-63B-4; ASVS 5.0 V3.3.3
SameSiteLax or Strict for session cookiesNIST SP 800-63B-4; OWASP Session Management Cheat Sheet
Cookie contentOpaque identifier only; SHALL NOT contain cleartext personal informationNIST SP 800-63B-4

The __Host- prefix is the strongest cookie scoping available: browsers reject a __Host- cookie unless it has Secure, no Domain attribute and Path=/, so it cannot be set or overwritten by a sibling subdomain. If you must share a cookie across hosts, use the __Secure- prefix, which ASVS V3.3.1 requires as the minimum. For the wider trade-off between cookies and tokens held by JavaScript, see Session Cookies vs Bearer Tokens.

Idle versus absolute timeouts

The inactivity (idle) timeout limits how long an unattended session stays usable; activity resets it. The overall (absolute) timeout caps the whole session regardless of activity, so a stolen token that an attacker keeps busy still dies. NIST SP 800-63B-4 requires that activity resets the inactivity timer, that successful reauthentication resets both timers, and that the session is terminated when either expires. Applications may warn the user before expiry so they can stay signed in by reauthenticating.

  • Enforce on the server: store issued-at, last-activity and AAL with the session record and check them on every request. OWASP's Session Management Cheat Sheet is explicit that timeout management must be enforced server-side; a cookie Max-Age is only a hint to the browser.
  • Do not trust browser close: a cookie without Expires or Max-Age is a session cookie, but browsers that restore tabs also restore session cookies "as if the browser was never closed", per MDN. OWASP likewise warns that browser close events cannot reliably enforce logout.
  • Define what counts as activity: background polling, keep-alive pings and auto-refreshing dashboards should not reset the idle timer, or the idle timeout never fires. Count only user-initiated requests.
  • Coordinate with the identity provider: in SSO, the IdP session, the RP session and any refresh tokens each have their own clocks. ASVS V7.1.3 and V7.6.1 require these to be documented and to force reauthentication when the maximum time between IdP authentication events is reached. See the OpenID Connect Logout and Session Management Guide.
  • Renewal timeout: OWASP also describes a renewal timeout after which the session ID is reissued mid-session, which shortens the useful life of any single captured identifier without logging the user out.

Remember-me token design

A remember-me feature issues a long-lived cookie that lets the user skip some steps on return. NIST SP 800-63B-4 is strict about what it may do: cookies and similar "remember my browser" features SHALL NOT be used in place of authentication, except for AAL2 reauthentication when the inactivity timeout has passed but the overall timeout has not. It also says bearer session secrets SHOULD NOT persist across an app restart or device reboot, while proof-of-possession secrets such as Device Bound Session Credentials may persist provided lifetime limits are still enforced. In practice, design remember-me as a way to restore a lower-risk session or skip the second factor on a known device, never as an indefinite login.

The selector-validator pattern

  1. Issue: on opt-in login, generate a random selector (lookup key) and a random validator (secret) from a CSPRNG. Set the cookie to selector:validator with __Host-, Secure, HttpOnly, SameSite=Lax or Strict and a Max-Age no longer than your policy allows.
  2. Store: save the selector, a SHA-256 hash of the validator, the user ID, the expiry and device metadata. As the Paragon Initiative design notes, a leaked token table then cannot be used to impersonate users because only hashes are stored.
  3. Verify: look up by selector, hash the presented validator and compare with a constant-time function. Timing in the lookup leaks only the selector, which is not secret; using the database row ID instead would leak how many tokens exist.
  4. Rotate: on each successful use, issue a fresh validator (and ideally a fresh selector) and invalidate the old one, so a copied cookie is only valid until the legitimate browser next returns.
  5. Detect reuse: if a selector arrives with a validator that does not match the current hash, treat it as possible theft: revoke all remember-me tokens for that user and require full authentication.
  6. Revoke: delete every token for the user on password change, MFA change, account recovery and explicit "sign out everywhere". The Paragon design and ASVS V7.4.3 both call for this.
Remember-me designStolen DB rows usable?Revocable per device?Verdict
Username or user ID in a cookieNot needed: trivially forgedNoNever acceptable
Long-lived session ID (session never expires)Yes, if session store leaksOnly by killing the sessionBreaks absolute timeout; avoid
Single random token stored in plaintextYesYesWeak; hash it
Selector plus hashed validator, rotated on useNoYesRecommended for bearer cookies
Device-bound (proof-of-possession) credentialNoYesStrongest where the browser supports it; see the Device-Bound Session Credentials (DBSC) Guide

What a restored session may do: a session rebuilt from a remember-me token should not carry more assurance than the token warrants. A common pattern is to restore a read-only or low-risk session and require step-up before payments, settings changes or data export, which fits the NIST rule that a session is never treated as higher than its authentication event.

Reauthentication for sensitive actions

Timeouts protect against unattended and stolen sessions over time; reauthentication protects specific high-impact actions even inside a fresh session. ASVS 5.0 sets the bar at three levels:

  • Account attributes (V7.5.1, L2): full reauthentication before changing email address, phone number, MFA configuration or any recovery information. These are the changes attackers make first to lock out the real owner.
  • Session management (V7.5.2, L2): users can view their active sessions and, after reauthenticating with at least one factor, terminate any or all of them.
  • Highly sensitive transactions (V7.5.3, L3): further authentication with at least one factor, or a secondary verification, before the operation runs.

After any reauthentication, issue a new session token and terminate the old one (V7.2.4); this also closes off fixation. NIST permits a lighter reauthentication at AAL2 once only the inactivity timeout has lapsed: the verifier MAY accept a password or biometric comparison together with the existing session secret. At AAL3 the overall limit is a hard SHALL of 12 hours. Phishing-resistant step-up with a passkey avoids training users to type passwords into prompts that appear mid-session. Reauthentication also limits the reach of cross-site request forgery, since a forged request cannot complete a fresh authentication.

Choosing timeouts by risk

NIST gives ceilings, not targets. ASVS V7.1.1 asks you to document your inactivity and absolute values, justify any deviation from SP 800-63B, and show how they combine with other controls. Start from the assurance level the application needs, then adjust for data sensitivity, shared devices and how quickly you can revoke.

ProfileInactivity timeoutOverall timeoutRemember-meBasis
AAL1, low-risk consumer contentOptional (NIST MAY)NIST: SHOULD be no more than 30 daysAllowed as reauthentication aid within the 30-day capSP 800-63B-4 s.2.1.3
AAL2, typical business SaaS or account with personal dataNIST: SHOULD be no more than 1 hour; OWASP cites 15 to 30 minutes for low-risk appsNIST: SHOULD be no more than 24 hours; OWASP cites 4 to 8 hours as an appropriate absolute rangeOnly for reauthentication after inactivity, before overall timeoutSP 800-63B-4 s.2.2.3; OWASP Session Management Cheat Sheet
AAL3, admin consoles, finance, health recordsNIST: SHOULD be no more than 15 minutes; OWASP cites 2 to 5 minutes for high-value appsNIST: SHALL be no more than 12 hoursNot used to bypass authenticationSP 800-63B-4 s.2.3.3

Decision guidance: small teams with one web app can enforce timeouts in the session store and keep a single profile. Larger estates with SSO should set the strictest profile at the IdP for privileged roles, map each application to an AAL, and audit that RP sessions do not outlive the IdP policy. Shorter idle timeouts on shared or kiosk devices are worth the friction; on a personal phone with a device-bound credential, a longer overall session can be justified. Whatever you choose, ASVS V7.1.2 also asks you to document how many concurrent sessions an account may hold and what happens at the limit.

Rolling out new timeouts

  1. Inventory every place a session or long-lived token is issued: web cookies, mobile refresh tokens, API sessions and IdP sessions.
  2. Add server-side issued-at and last-activity checks in log-only mode and measure how many sessions would have ended.
  3. Pilot the new values with internal users, then a percentage of customers, watching support tickets and login volumes.
  4. Migrate remember-me tokens to selector-validator by issuing new tokens on next login and expiring old-format cookies on a fixed date.
  5. Keep a configuration flag to restore the old values quickly if a business process breaks, and record any exception with an owner and expiry.

Detection and measurement

  • Log session creation, reauthentication, timeout, logout and admin termination events with session ID hash, user, AAL and client details; ASVS V7.4.5 requires that administrators can terminate one user's or all users' sessions.
  • Alert on remember-me validator mismatches (possible theft) and on the same session used from distant locations or new device fingerprints.
  • Metrics: median and 95th percentile actual session length against policy; share of applications with documented timeouts per ASVS V7.1.1; time from password or MFA change to revocation of all other sessions; count of sessions older than the overall limit (target zero); step-up completion rate for sensitive actions.

Framework mapping

FrameworkReferenceWhat it covers
NIST SP 800-53 Rev. 5AC-12 Session TerminationAutomatic termination after defined conditions
NIST SP 800-53 Rev. 5IA-11 Re-authenticationReauthentication under defined circumstances
NIST SP 800-53 Rev. 5SC-23 Session AuthenticityProtecting session identifiers and invalidating them at logout
NIST SP 800-53 Rev. 5AC-11 Device LockLock after inactivity on the endpoint
OWASP ASVS 5.0V7 Session Management; V3.3 Cookie SetupTimeouts, termination, reauthentication, cookie attributes
MITRE ATT&CKT1539 Steal Web Session Cookie; T1550.004 Web Session CookieTechniques that timeouts and revocation limit

Common failure patterns

  • Patching without killing sessions: in CitrixBleed 2023, session cookies stolen before patching kept working afterwards, and the vendor told customers to kill all active and persistent sessions. Any credential or token exposure response must include mass session revocation; see How to Revoke All Sessions for a Compromised User.
  • Client-only logout: clearing the cookie while the server session or JWT stays valid. OWASP notes that deleting a cookie alone does not invalidate a stolen copy.
  • Remember-me as a permanent login: a 1-year cookie that restores a full-privilege session with no step-up turns infostealer logs into account takeover. See the Infostealer Logs and Session Token Abuse Guide.
  • Keep-alive traffic resetting idle timers: single-page apps that poll every minute never reach the inactivity timeout.
  • No session ID change at login: reusing a pre-login identifier enables fixation; see the Session Fixation Guide.
  • Password reset that leaves other sessions alive: the attacker who prompted the reset stays logged in. Offer, or force, termination of other sessions under ASVS V7.4.3.

Practitioner checklist

  • Map each application to an AAL and document idle and absolute timeouts, with justification for any deviation from SP 800-63B-4.
  • Enforce both timeouts server-side from stored issued-at and last-activity values; never rely on cookie expiry.
  • Set session cookies with __Host-, Secure, HttpOnly, Path=/ and SameSite=Lax or Strict, holding only an opaque identifier.
  • Issue a new session token at login and every reauthentication and terminate the old one.
  • Build remember-me with a selector and hashed validator, constant-time comparison, rotation on use and reuse detection.
  • Use remember-me only to ease reauthentication within the overall limit; require step-up for sensitive actions.
  • Require full reauthentication before changing email, phone, MFA or recovery settings.
  • Invalidate sessions at the backend on logout, account disablement and credential change, including all remember-me tokens.
  • Give users and administrators a way to see and terminate active sessions.
  • Include mass session revocation in incident runbooks for token or credential exposure.

Standards and references

Related NHI Mgmt Group resources: Session Hijacking and Cookie Theft Guide · Device-Bound Session Credentials (DBSC) Guide · Session Cookies vs Bearer Tokens · Session Token Theft Response Playbook

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.