İçeriğe geç
wedevit

November 24, 2026 · 9 min read · software

İlhan Buğra Aslan

Users say the app logs them out constantly, auditors ask why sessions never end: designing session management


Session management is not one timeout setting. It is three separate decisions: how long a session survives with no activity, how long it may last even with constant activity, and where the session lives so it can be revoked. When users complain that the app keeps logging them out and an auditor asks why sessions never seem to end, both complaints usually trace back to the same mistake, which is trying to express everything through a single token lifetime. A setup that works has three parts: a short-lived access credential, a server-side session record that can be revoked, and limits that differ by role.

The two timeouts people conflate

An idle timeout ends the session after a period with no requests. An absolute timeout ends it after a fixed span no matter how active the user was. Applications that configure only one of them land at one extreme or the other: either the person who logs in at nine and leaves the tab open never reauthenticates for weeks, or the person reading a report for five minutes gets thrown out. Whichever expires first terminates the session. Activity resets only the idle counter, while a successful reauthentication resets both.

Where the current numbers come from

The fourth revision of NIST SP 800-63B was published in July 2025 and supersedes the 2020 edition. The current limits read as follows: at AAL1 the overall timeout should be no more than 30 days and an idle timeout is optional. At AAL2 the recommended ceilings are 24 hours overall and one hour of inactivity. At AAL3 the overall timeout must not exceed 12 hours, which is a requirement rather than a recommendation, with an idle limit of 15 minutes. The "12 hours and 30 minutes for AAL2" figures still circulating in vendor documents come from the superseded revision, so keep them out of anything that cites the current standard. There is one AAL2 detail worth using. If the idle timeout has passed but the overall timeout has not, the verifier may accept a password or biometric comparison alone in combination with the session secret. You do not have to drag the user through the full second factor every time they come back from lunch.

Picking actual values

The OWASP session management guidance gives working ranges: 15 to 30 minutes of idle time for low-risk applications, 2 to 5 minutes for high-value ones, and 4 to 8 hours as an absolute lifetime matching a working day. You are not obliged to apply one number across the whole product, and you should not. An internal admin console and a customer portal do not carry the same risk. Two rules are not negotiable: timeouts are enforced server side, and a cookie expiry is not a timeout mechanism. NIST states this plainly. Clocks can be changed, cookies can be copied by hand, and the decision has to sit with the server.

Where the session actually lives

In the browser the session travels in a cookie, and the cookie attributes are settled questions: Secure, HttpOnly, an explicitly set SameSite (Strict where possible, Lax where it is not), no Domain attribute, and the __Host- prefix together with Path=/. The cookie value should be meaningless. No user id, no role, no email address; all of the meaning stays on the server. The session identifier must come from a cryptographic random generator with at least 64 bits of entropy, or 128 bits if you are rolling your own scheme. Keeping an access token in localStorage is the classic mistake that turns any XSS into full account takeover, because injected script runs with exactly the same privileges as your own application code.

Single-page and mobile clients: three architectures, three risk levels

RFC 10017, published by the IETF in August 2026, ranks three patterns for browser applications by security. The strongest is the backend for frontend: tokens stay on the server, the browser holds a cookie-based session, requests are proxied, and no token ever reaches JavaScript. The document strongly recommends it for business applications, sensitive applications, and anything handling personal data. Second comes the token-mediating backend, which runs the flow server side but hands the access token to the browser, so there is no proxy overhead and less protection. Third is the browser-based public client holding its own tokens, exposed to every attack scenario the document lists. Start a new dashboard with the first pattern. Buying authentication instead of building it does not remove this decision, it only makes implementing it easier.

Refresh token rotation

RFC 9700 (January 2025, BCP 240) sets a clear requirement for public clients: refresh tokens must either be cryptographically bound to a client instance or rotated on every use. Rotation is simple to implement. On each refresh the authorization server issues a new refresh token, invalidates the previous one, and keeps the relationship between them. If an invalidated token shows up again, something has leaked, and the server cannot tell whether the request came from the attacker or the legitimate client. So it revokes the active refresh token as well, which forces both parties back through authorization and the real user through one extra login. The RFC also recommends expiring refresh tokens after a period of client inactivity and revoking them automatically after events such as a password change or a logout. Together these three cut the useful life of a stolen token from days to minutes.

Does logout actually log anyone out

Deleting a cookie does not end a session. The session has to be invalidated server side, and the invalidation has to cover every identifier belonging to the logical session, including rotated ones and any still inside a renewal grace window. Adding Clear-Site-Data to the response and Cache-Control: no-store on sensitive pages finishes the job. Teams using stateless JWTs have to accept one thing: a signed token cannot be revoked, it can only expire. That is the whole reason access tokens are measured in minutes while revocation lives in the refresh token and the server-side session record. Enterprise customers add another layer, since logging out of your application does not end the session at their identity provider. OpenID Connect's back-channel logout profile exists for exactly that gap and it is the part of an SSO integration teams most often skip.

Regenerating the session identifier

Issue a new session identifier the moment a login succeeds and destroy the old one. Do the same on password change, privilege escalation and role change. Never accept a session identifier the server did not generate; when one arrives, replace it and log the event as suspicious. Skip this and you have a session fixation hole: the attacker plants an identifier in the victim's browser, the victim logs in, and the attacker walks in on the same identifier. Account recovery, email changes and sign-ins from unrecognised devices are also good places to demand reauthentication.

A stolen session cookie walks straight past MFA

Recorded Future's 2025 identity threat report found that 276 million of the credentials it indexed that year came with active session cookies, which is 31 percent of the credentials sourced from malware. An attacker holding a valid session cookie needs neither the password nor the MFA prompt. "We turned on MFA" therefore says nothing about session security. The practical countermeasures are three: shorten session lifetime, give users a screen that lists their active sessions with a way to sign out other devices, and write session events (login, refresh, logout, IP and device change) into the audit trail.

Binding the cookie to the device: DBSC

Google moved Device Bound Session Credentials, the protocol that binds a cookie to a device, into general availability on Windows with Chrome 146, announced on 9 April 2026, with macOS to follow in a later release. The mechanics: at login the browser generates a key pair, keeps the private key in secure hardware such as a TPM where one exists, the site issues a short-lived cookie (10 minutes in Chrome's own example), and each time the cookie expires the browser presents a signed proof to a refresh endpoint. Sites add two endpoints and change nothing in the front end. Know the boundaries too: it does not protect plain HTTP requests, malware present on the device at registration time may be able to extract the key, and devices without secure key storage fall back to ordinary cookie behaviour. It sits on top of server-side session hygiene rather than replacing it.

What you can do this week

Four steps. Find your current idle and absolute timeout values and write them down, because in most teams they are framework defaults nobody has looked at. Configure the two separately and keep the admin console shorter than the rest. Turn on refresh token rotation and reuse detection for public clients. Then test the logout path from the server's side: log out, and send an API request with the cookie or token you still hold. If it does not come back 401, your sessions are not ending, and none of the other settings matter.


Need help with this topic?

get in touch →← all posts