← All articlesWeb security

Logging out: revoke the session and verify the result

After you click Log out, the site displays a sign-in form. That still leaves the main question unanswered: will the server accept the old session? Here is how to define what logout ends, test the result in your own environment, and treat an independent login on another device as a separate scenario.

Define what the button actually ends

Consider a fictional team task-planning service. A test user signs in independently in browser profiles A and B. A Log out on this device button should end session A; the independent session in B may remain active. End all sessions makes a different promise: both should lose access. These scenarios need different expectations.

With single sign-on, the application and identity provider may maintain separate sessions. Logging out of the application does not always end the provider session. Tell users what the button actually does, and include the relevant boundaries in your test plan.

Deleting a cookie does not revoke a session

OWASP recommends ending the session on the server when the user logs out. With a server-side session store, each private request should check the session state and expiry. A previously issued identifier must stop opening protected data once revoked. Deleting a cookie cleans up the browser; it does not invalidate another saved copy of that identifier.

Enforce idle and absolute session timeouts on the server. Choose their duration for the product and the sensitivity of its data. Closing a tab or browser is no substitute: a browser may restore session cookies when it starts again.

Check access and refresh tokens separately

A signed JWT may still pass signature and exp checks after the user logs out. Immediate termination requires a revocation mechanism that the API checks, such as a denylist of server-issued jti identifiers until token expiry, or a link to an active session. Removing a token from the client does not change the server’s validation result.

Revoking a refresh token prevents further access renewal, but does not by itself guarantee that an existing access token has been revoked. Confirm your provider’s behavior and test both outcomes. If the product permits a delay before access ends, document it; a short token lifetime should not be presented as immediate revocation.

Run a controlled test in your own environment

Use staging, a test account and synthetic tasks. First obtain a successful response from a private read-only API for your own test data: this is the positive control. Then log out normally in profile A. Repeat that request once with the saved session from A using your team’s test tools to establish whether the server recognizes the revocation. Keep cookie and token values inside the test; do not publish them in the report.

Inspect the response body: an HTTP status alone does not establish that private data is absent. Empty results and network failures do not prove correct authorization either. Make a separate control request in profile B and compare its result with the promised behavior of local or global logout.

  • Test a new private request without a session after logout.
  • Test reuse of the revoked test session from profile A.
  • Test access-token renewal with the previous refresh token.
  • Check a neighboring tab and the independently signed-in profile B.
  • Repeat the checks after the configured server-side session expiry.

Browser cleanup and caching need their own checks

When deleting a cookie, the server must account for its name, Path and Domain scope. For a host-only cookie, do not add a Domain attribute that was not present originally. Max-Age=0 expires the cookie; clear HttpOnly cookies through a server Set-Cookie response rather than document.cookie. Reset private UI state too, so the next person using that browser does not see the previous user’s tasks.

The Back button may display a historical page snapshot. Distinguish it from a fresh response from the private API. Cache-Control: no-store prevents HTTP caches from storing the response; no-cache permits storage with revalidation. Neither setting revokes a session or replaces application-state cleanup.

Do not confirm server logout when it has not completed

If the logout request fails because of a network error, the UI should not promise successful server-side revocation. Local data can be cleared, but the server’s completion status remains unknown. Provide a clear message and a safe retry of the normal operation.

In a distributed application, check the result across all components serving private requests. A failure on one route or stale state on another may leave access available. Record the route, logout time, status and presence of test data for the report; do not retain session secrets.

Turn the results into a repeatable check

Create a table of scenario, expected behavior, observed result and owner. Fix server-side revocation first, then align access and refresh handling, clean up the browser and retest private routes. Keep these scenarios as regression checks: displaying a sign-in screen should not be the only success criterion.

You can start investigating your product with a free CheckMyApp website or web-application audit using the button below. Verifying specific session behavior also requires test accounts and an understanding of the chosen authentication design.

Sources and documentation

  1. OWASP — Session Management Cheat Sheet
  2. OWASP — REST Security Cheat Sheet
  3. MDN — Set-Cookie header
  4. MDN — Using HTTP cookies
  5. MDN — Cache-Control header
CheckMyApp

Check your application’s security.

Enter your web application address and email. Get a free preliminary report and choose the depth of analysis.

Check for free