termEngineering & architecture

Session

A bounded continuity context that associates a sequence of interactions with authenticated state and other server-recognized information.

Download Markdown (.md)

01What it means

A session maintains continuity across otherwise independent requests. After authentication, a service commonly issues an unpredictable session identifier and stores the associated identity, assurance, timestamps, and state server-side; other designs carry protected state in a token. A cookie is one transport mechanism for a session identifier, not the session itself.[1][2]

Continuity across independent requests An unpredictable identifier links requests to bounded authenticated state
  1. 01CreateAuthenticate and issue high-entropy identifier
  2. 02Store stateIdentity, assurance, timestamps, expiry
  3. 03Transport safelyCommonly Secure HttpOnly cookie
  4. 04Validate + authorizeCheck each protected request
  5. 05Rotate or revokePrivilege change, expiry, logout, compromise

A cookie may transport the identifier but is not the session itself; every protected request still requires session validation and authorization.

02Why it matters

Sessions let products remember authentication and workflow state without asking users to prove identity on every request. Their creation, rotation, expiry, revocation, and protection determine how long stolen access remains useful.

03When to use it

Use a session when several interactions need shared authenticated or workflow context. Keep truly stateless public requests independent, and require reauthentication rather than trusting an old session for sufficiently sensitive actions.

04How it works

  1. Authenticate the actor and create a high-entropy session identifier.
  2. Store minimal session state with identity, assurance, creation, activity, and expiry data.
  3. Send the identifier through a protected channel, commonly a secure HTTP-only cookie.
  4. Validate the session and authorize each protected request.
  5. Rotate identifiers after authentication or privilege change and expire them by inactivity and maximum lifetime.
  6. Revoke sessions on logout, compromise, account changes, or administrative action.

05A practical example

Example

After login, a banking site stores an opaque session identifier in a Secure, HttpOnly cookie. It rotates the identifier after authentication, expires idle sessions, and requires fresh authentication before adding a payee.

06Where it breaks

A valid stolen session can bypass the original login factors. Distributed storage and revocation add operational cost, while long lifetimes increase exposure and short lifetimes disrupt users.

Common mistakes

  • Putting predictable identity data directly in a session identifier.
  • Failing to rotate the identifier after login and enabling session fixation.
  • Treating logout as a client-side deletion without server-side invalidation.
  • Using one lifetime for inactivity, absolute expiry, and sensitive reauthentication.

07Sources

  1. Digital Identity Guidelines: Session ManagementNIST · Government standardDigital Identity Guidelines: Session Management
  2. Session Management Cheat SheetOWASP Foundation · Security practice guidanceSession Management Cheat Sheet
View saved topics

Start typing to search titles, definitions, categories, and frameworks.