What is Session Token?
Updated: Oct 28

A session token is a value that helps a service recognise an ongoing session across related requests. In a common web application, the server issues an unpredictable session identifier and the browser returns it with later requests. The server uses that value to find and check the associated session state.
A session token may be issued after a user signs in, but an application can also maintain an anonymous session before authentication. Terminology and formats vary between systems. A token can be a sensitive credential: if it is a bearer token, someone who obtains a valid copy may be able to use the session until the service rejects it.
How does a session token work?
Imagine a user signs in to a customer portal. After verifying the user, the application establishes an authenticated session and issues a session identifier. The browser commonly receives that identifier in a cookie and sends the eligible cookie with later requests. The application checks the session and the user's permissions before returning protected information.
The illustration shows a simplified server-managed flow: a user signs in, the service issues a session token, the client presents it and the service checks the associated session.

The client starts a session and the user authenticates when required.
The service issues an unpredictable session token and associates it with session state.
The client stores and sends the token using the supported mechanism over a secure connection.
The service checks the token, session status and applicable timeout rules.
The application checks whether the requested action and resource are authorised.
The service renews or invalidates the session according to its policies.
The steps depend on the application. An anonymous session may exist before sign-in, and its identifier should be renewed after authentication or other relevant privilege changes to help prevent session fixation.
What does the token contain?
In a server-managed design, the token is often an opaque, randomly generated identifier. It points to state held by the service rather than containing a readable copy of the user's account details. The application must protect the server-side store and check that the identifier maps to a valid session.
Other designs use signed or encrypted tokens that carry claims, subject to their protocol and validation rules. Do not assume a token is a JWT, or that a readable token is encrypted. The token format alone does not determine whether the user has permission to access a particular resource.
The OWASP session management guidance explains identifier generation, secure handling, session renewal and server-side invalidation. Use a maintained framework and check its configuration rather than inventing a custom session mechanism.
Session token, session ID and cookie
A session ID is a value used to identify a session. In many applications, “session token” and “session ID” refer to the same opaque value, although a provider may use the terms differently. Check its documentation for the actual meaning and lifecycle.
A cookie is a browser mechanism that stores a value and sends it with eligible requests. It can carry a session token, but not every cookie is a session token and not every session uses a cookie. A cookie's browser lifetime is separate from the server's decision to accept or reject the associated session.
Term | Typical role | Important distinction |
|---|---|---|
Session | Ongoing interaction or state tracked by a service | May be anonymous or authenticated |
Session token or ID | Identifies or helps bind a client to a session | Can be a sensitive credential |
Cookie | Browser mechanism for carrying a value | Its attributes affect when it is sent |
Access token | Credential presented to an intended resource | Its purpose and recipient depend on the protocol |
Refresh token | Credential for obtaining replacement tokens | Normally presented to an authorisation server, not a resource API |
A browser can retain a cookie even after the server has ended its session. A session cookie has no explicit expiry or maximum age, but browser session restoration can affect when it is removed. Closing a browser is not a universal guarantee that server-side access has ended.
Is a session token the same as an access token?
Not necessarily. A session token commonly maintains an application's session, while an OAuth access token is used to request access to a protected resource. Some products use the same words for different credentials or implement a combination, so identify the issuer, intended recipient and actual purpose before making assumptions.
Token based authentication describes a broader family of token uses. An OpenID Connect ID token communicates authentication claims to a relying application; it is not a general-purpose API access token. A valid session token also does not automatically authorise every action.
A session may be maintained with a browser cookie while the application's server separately holds an API access token. Those credentials can have different expiry, refresh and revocation rules. The application, identity provider and API must each enforce the controls relevant to them.
Why must a session token be protected?
A bearer-style session token can often be used by whoever possesses it. Theft through malicious script, compromised devices, logs, network interception or a public support message may let an attacker impersonate the session. A token that merely looks random or encoded is not automatically safe to expose.
Protect the full connection with HTTPS, keep session credentials out of URLs and logs, and restrict access to the session store. Generate unpredictable identifiers with a cryptographically secure random mechanism. Rotate the identifier after authentication and other relevant privilege changes, and ensure the old value is no longer accepted according to the application's design.
NIST's current digital identity guidance describes session secrets and protected session binding for the assurance contexts it covers. Some technologies prove possession of a key instead of relying solely on a bearer value; their availability and behaviour depend on the implementation.
Cookie settings and browser risks
When a browser cookie carries a session token, its attributes need careful configuration. Secure restricts sending it to secure connections under browser rules. HttpOnly prevents JavaScript from reading the cookie directly. SameSite limits some cross-site cookie sending. Scope the domain and path appropriately for the application.
These controls address different threats and are not substitutes for one another. HttpOnly does not stop malicious script from issuing requests in the user's browser, and SameSite does not replace every cross-site request forgery defence. Prevent cross-site scripting, protect state-changing requests and enforce server-side access checks. MDN's cookie guide describes the relevant browser behaviour.
Avoid placing a secret token in browser-delivered source code, local storage or other locations without understanding the application's threat model. Client-side scripts and compromised devices can expose credentials. An HttpOnly cookie can reduce direct JavaScript access to its value, but the entire application still needs to be secured.
Expiry, renewal and logout
A session can have an idle timeout, an absolute lifetime or both. The service must enforce its own expiry rules rather than relying only on the browser deleting a cookie. A token that remains in the browser should be rejected when its server-side session has expired or been revoked.
Renewal can replace a token or require fresh authentication, depending on the design. Rotating a token without invalidating the previous one may leave an attacker with access. Reauthentication and token rotation are related but separate actions: one checks the user again, while the other changes a credential.
On logout, the application should invalidate the appropriate server-side session and remove or expire the browser cookie where applicable. Deleting a cookie from one browser alone does not necessarily invalidate a copied token or sign out other devices. Session management covers the wider lifecycle and its checks.
What happens if a session token is stolen?
Follow the organisation's incident process. Invalidate the affected session or sessions using the service's supported controls, investigate how the token was exposed and check for unauthorised activity. Depending on the incident, also review the user's account, connected identity-provider sessions, API credentials and affected devices.
Do not paste the suspected token into public tools or support messages. Record safe correlation identifiers, timestamps and events instead. Changing a password may not automatically end existing sessions in every system, so verify the actual revocation behaviour rather than assuming the problem is resolved.
If a session credential or signing key can affect many users, the response may involve broader invalidation or key rollover. The correct steps depend on the application, its dependencies and the risk of continued access. Test recovery and communicate clearly with affected users under the organisation's procedures.
A practical UK example
Imagine an engineer at a UK support business signs in to a customer portal. This is an illustrative example, not a tested deployment or a claim about a particular product.
The portal creates a server-managed session and gives the browser an opaque token in a suitably configured cookie. When the engineer requests a case, the server checks the token's session and whether that engineer may access the specific customer's case.
Situation | Intended result | What to check |
|---|---|---|
Engineer requests an assigned case | Allow if the session and permissions are valid | Session status and customer-level authorisation |
Token has expired | Reject the request or require a fresh sign-in | Server-side expiry and client behaviour |
Engineer signs out | End the portal session | The old token is rejected by the server |
Token is suspected stolen | Contain and investigate | Revocation, activity logs and other affected sessions |
Engineer changes team | Remove unneeded access under policy | Active session permissions and cached state |
The identity provider's session and any API tokens may remain separate from the portal's session. Test the complete access-removal process, including other devices and connected services.
Common session token problems
Repeated sign-in: the token may be missing, expired or rejected because of cookie scope, browser settings or session-store failures.
Invalid token after deployment: the application may have lost session state or changed a required key or configuration.
Logout appears incomplete: a different device, identity-provider session or copied token may still be active.
Token accepted but access denied: the user may lack the required permission for that resource.
Another user's data appears: investigate session isolation, caching and authorisation immediately under the incident process.
Use authorised test accounts and non-sensitive data. Trace the request using safe identifiers and timestamps, never the complete session token. Verify that expired, invalid, revoked and unauthorised requests are rejected.
Key takeaway
A session token helps a service connect related requests to an ongoing session. Its security depends on unpredictable generation, protected handling, appropriate lifetime, server-side checks and effective invalidation. The application must still enforce permissions for every protected action.
Frequently asked questions
What is a session token?
A session token is a value used by a service to recognise or maintain an ongoing session across related requests.
Is a session token the same as a cookie?
No. A token is a session value or credential; a cookie is a browser mechanism that can carry it.
Is a session token always a JWT?
No. Many session tokens are opaque identifiers, while some systems use other formats under their own validation rules.
Does a session token prove a person has signed in?
Not always. Applications can create anonymous sessions. The service must check whether the associated session is authenticated and suitable for the requested action.
Can a stolen session token be reused?
A valid bearer-style token can often be reused by whoever obtains it until it expires, is revoked or another effective control prevents use. HTTPS and appropriate cookie controls reduce particular exposure routes, but they do not make a token harmless after theft. Invalidate affected sessions through the service's supported process, investigate the source of exposure and check other active sessions rather than only changing the local cookie.
Does logging out invalidate every session token?
Not necessarily. The effect depends on the application's logout design, other devices, connected identity-provider sessions and token lifecycles.
Should I share a session token with support?
Do not share a live token through public tickets, screenshots or messages. Use safe request identifiers and follow the service's approved support process.

