top of page

What is Session Expiry?

Oct 27
8 min read

Updated: Oct 28

What is Session Expiry?

 

Session expiry is when a service stops accepting an existing session because its permitted lifetime or another session condition has been reached. For an authenticated website, the user may need to sign in or reauthenticate before continuing. The exact behaviour depends on the application, its identity provider and the type of session involved.

 

Expiry helps limit how long an unattended or stolen session can remain usable. It does not prevent a session credential being stolen, and it does not automatically end every connected application session or API token. The service must enforce its own rules and reject requests that no longer meet them.

 

How session expiry works

 

A session lets a system associate related activity with an ongoing interaction. In a common server-managed website, the browser sends a session identifier with eligible requests and the application checks its stored session state. That state can include when the session was established and when qualifying activity last occurred.

 

The illustration shows a simplified authenticated session: a user signs in, the relevant timeout rules apply, the service stops accepting an expired session and the user reauthenticates when required.

 

Session expiry infographic showing sign-in, timeouts, expiry and reauthentication

 

  1. The application establishes a session and applies its configured policy.

  2. The service tracks the information needed to enforce relevant timeouts.

  3. Qualifying user activity may reset an inactivity timer, depending on the design.

  4. A maximum session age or reauthentication deadline may still apply.

  5. When a limit is reached, the service rejects the expired session or requires the appropriate reauthentication flow.

  6. The client informs the user and handles the return to work safely.

 

The server should be authoritative about session validity. A visible countdown or a cookie disappearing in the browser is not a substitute for checking the session when the service receives a request. The OWASP session management guidance explains idle and absolute timeouts and server-side enforcement.

 

Idle timeout and absolute timeout

 

An idle timeout applies after a period without qualifying activity. An absolute timeout limits the session's total age according to the application's policy, regardless of ordinary activity. A system may also use an overall reauthentication deadline that can be reset by successful reauthentication under its rules.

 

Limit

What it controls

Example

Idle timeout

Time since qualifying activity

A portal ends a session after an idle period

Absolute timeout

Maximum permitted session age

A session ends after its configured maximum age

Reauthentication deadline

When the user must authenticate again

A service requires fresh authentication after a set period

Cookie expiry

How long a browser retains a cookie under its rules

A browser removes a persistent cookie at its configured expiry

Access token expiry

When an API token is no longer accepted under its rules

A client needs a replacement token for an API

 

These are illustrative mechanisms, not universal durations. A background request, notification check or automatic refresh may or may not count as activity. The application should define which events reset an idle timer so that automated traffic does not unintentionally keep an unattended session alive.

 

A timeout after inactivity and an absolute maximum address different risks. An active session can continue to reset an idle timer but still reach an overall limit. Whether reauthentication extends or replaces a session depends on the application's policy and protocol.

 

Why do sessions expire?

 

Session expiry reduces the window in which an unattended browser or a stolen valid session identifier can be used. It can also require periodic confirmation that the user is still present. A shorter lifetime may reduce exposure, but it can interrupt legitimate work and does not stop an attacker from using a valid stolen credential before expiry.

 

The right setting depends on the sensitivity of the data, device and environment, user needs, applicable requirements and the impact of interruption. A public information page, customer portal and administrative console may need different policies. Avoid treating a single suggested number as suitable for every service.

 

NIST's current session management guidance discusses inactivity and overall timeouts and reauthentication in its specified digital identity assurance contexts. Its requirements and recommended limits should be applied in their stated scope, not assumed to govern every website.

 

Session expiry, cookie expiry and token expiry

 

A cookie is a browser mechanism for holding and sending a value; it is not the server's session policy. A persistent cookie can remain in the browser after the server has invalidated its session. A session cookie has no explicit expiry or maximum age, but browsers may restore session cookies after a restart. Closing a browser does not universally terminate server-side sessions.

 

A session token may identify a server-managed session. An access token can separately allow a client to call an intended API, and a refresh token may allow replacement tokens to be obtained. These credentials can have different lifetimes and revocation mechanisms. Expiry of one does not necessarily invalidate the others.

 

The MDN cookie guide describes expiry attributes and browser behaviour. Treat cookie settings, application session checks and token validation as related but distinct parts of the design.

 

Event

Possible effect

What must be checked

Browser cookie expires

Browser stops sending that cookie

Whether the server session is also invalidated

Application session expires

Application rejects that session

Client response and reauthentication path

API access token expires

API rejects that access token under its policy

Refresh and replacement behaviour

User logs out

The intended session should be ended

Server-side invalidation and other connected sessions

Account is disabled

New access should follow the organisation's policy

Existing sessions, tokens, caches and provider behaviour

 

Does expiry log you out everywhere?

 

Not necessarily. A website, identity provider, mobile app and API can each manage separate sessions or credentials. One application can require a new sign-in while the identity provider still has a valid session, allowing the application to establish a new session without another visible password prompt, depending on the protocol and policy.

 

Single sign on makes this distinction especially important. A requirement for fresh authentication may need the application to request and verify the appropriate authentication recency. Do not assume that a redirect to the identity provider means the person has just entered credentials again.

 

A “log out everywhere” or account-disable feature needs an explicit design across the relevant applications and tokens. Test what happens to existing sessions, refresh credentials, caches and devices, including the time it takes for access changes to take effect.

 

What happens when the connection drops?

 

A temporary network interruption is not necessarily session expiry. The server may retain the session while the client is offline, and the client may continue when connectivity returns if the session remains valid. The idle or overall limit may still be reached during the outage.

 

Long-running tasks need special attention. A download, upload or background job can use a different authorisation or connection mechanism from the website session. A page becoming unauthenticated does not by itself prove that every active transfer has stopped. Test the actual service and ensure any resumed action remains authorised.

 

Unsaved work can also be lost when a session expires. Where the application supports it, warn the user before expiry, preserve non-sensitive work safely and provide a clear path back after reauthentication. Do not silently resubmit a sensitive operation without considering duplication and the user's intent.

 

How should an application handle expiry?

 

The server should reject expired session credentials and stop relying on the associated authenticated state. The client should present a clear message and offer the supported sign-in or reauthentication process. A warning before expiry can help, provided that it does not itself keep an unattended session alive unintentionally.

 

  • Define idle, absolute and reauthentication rules for the application's risk and users.

  • Make the server responsible for enforcing the relevant deadlines.

  • Specify which actions count as activity and how background traffic is handled.

  • Invalidate or renew credentials appropriately after login and privilege changes.

  • Preserve work safely and avoid exposing sensitive information on shared devices.

  • Test logout, account suspension and connected identity-provider or API lifecycles.

 

Session management covers the wider lifecycle, including identifier protection, renewal and server-side invalidation. Expiry is one control within that lifecycle, alongside authentication, authorisation and incident response.

 

A practical UK example

 

Imagine a UK support business using a customer portal on engineers' laptops. This is an illustrative example, not a tested configuration or a claim about a named service.

 

The portal applies an inactivity limit and an overall reauthentication policy. It warns an engineer before the idle limit, then rejects the existing session if the limit is reached. The application checks permissions again when the engineer returns to a customer case.

 

Situation

Intended behaviour

What to test

Engineer actively works on an assigned case

Continue while the session remains valid

Which actions reset the idle timer

Laptop is left unattended

End or require reauthentication after the limit

Server-side enforcement and warning

Engineer keeps working for a long period

Apply the overall policy

Whether reauthentication resets the relevant deadline

Connection drops temporarily

Resume only if the session remains valid

Expiry during outage and unsaved work

Account is disabled

Remove access under policy

Existing sessions, API tokens and caches

 

The portal and its identity provider can have separate sessions. A successful return to the portal does not necessarily mean a fresh password or MFA challenge occurred unless the application requested and verified the required authentication conditions.

 

Troubleshooting unexpected session expiry

 

  • Frequent sign-in: check the idle and overall policies, browser cookie settings and whether a shared session store is available.

  • Expiry despite activity: check which events reset the timer and whether activity is reaching the correct application instance.

  • Session survives longer than expected: check whether background requests reset inactivity, whether every server enforces expiry, and whether a separate identity-provider session creates a new application session.

  • Expiry after deployment: check session-store persistence, shared signing keys and configuration across instances.

  • User is signed in but an API request fails: check the separate access token's audience, expiry, refresh and permissions.

  • Work disappears: check the client recovery path, local state handling and any server-side draft policy.

 

Use authorised test accounts, non-sensitive data, safe request identifiers and timestamps. Do not collect or share live session cookies or tokens in screenshots, logs or public support messages.

 

How to test expiry

 

  1. Document the intended idle, absolute and reauthentication rules and their start points.

  2. Confirm that the service rejects an expired credential, even if the browser still holds it.

  3. Check which foreground and background events reset the idle timer.

  4. Test expiry during active work, a network outage, browser restoration and multiple devices.

  5. Verify reauthentication, safe recovery of work and enforcement of resource permissions.

  6. Test logout, account disablement and connected identity-provider and API token behaviour.

  7. Repeat across application instances and after deployments or session-store failures.

 

Authentication confirms a claimed identity or credential. A valid session represents a continuing relationship under the application's rules; it should not be treated as unlimited permission or proof that the user is still physically present.

 

Key takeaway

 

Session expiry limits how long a service accepts an ongoing session. Effective expiry depends on server-side enforcement, clear idle and overall policies, appropriate reauthentication and testing across cookies, identity providers and tokens.

 

Frequently asked questions

 

What is session expiry?

 

Session expiry is when a service stops accepting an existing session because its configured lifetime or another session condition has been reached.

 

What is an idle timeout?

 

An idle timeout applies after a defined period without qualifying activity, which the application must define.

 

What is an absolute session timeout?

 

It is a maximum permitted session age under the application's policy, regardless of ordinary activity. Unlike an idle limit, it is not normally extended by ordinary clicks or background requests. The service can require a new authenticated session or supported reauthentication when the limit is reached. Distinguish that maximum session age from a separate token's expiry.

 

Does closing the browser always expire a session?

 

No. Browser restore, cookie persistence and server-side policies differ. Closing the browser does not guarantee that the server has invalidated the session. The server must enforce its own session lifetime and invalidation. Closing a window or clearing one device's cookie does not necessarily remove the corresponding server record or sessions on other devices. Use the service's logout and session-management controls when ending access deliberately.

 

Does a lost internet connection end my session?

 

Not necessarily. The session may remain valid during an interruption, although its timeout can be reached while the client is offline.

 

Does session expiry revoke API access tokens?

 

Not automatically. An application session, API access token and refresh token can have separate lifetimes and revocation rules.

 

Why was I signed back in without entering a password?

 

The identity provider may still have a valid session, allowing a new application session under its policy. A fresh authentication prompt depends on the requested and verified conditions.

 
 
UK Techie Broadband Providers
bottom of page