Home / patterns

Sessions that stay valid after logout, password change or timeout

A laptop left open and signed in on a library table next to a coffee cup, while its owner walks away with a backpack in the background
Quick answer: AI-built apps often "log out" by deleting a cookie or token in the browser and redirecting to the home page. The session itself is never ended on the server, so anyone who copied that token (from a shared computer, a leaked log or an XSS bug) can keep using it. The same happens when a user changes their password or an admin removes access but old sessions keep working, or when tokens never expire at all.

Last updated November 9, 2026

Steps

  1. Test it: log in, copy your session cookie or token, log out, then replay a request with the copied value (curl or your browser dev tools). If it still works, sessions aren't invalidated.
  2. Repeat the test after a password change, an email change and an admin disabling the account. Old sessions should stop working in each case.
  3. End sessions on the server at logout: delete the session record or revoke the token, not just the cookie.
  4. Enforce an idle timeout and an absolute timeout on the server, sized to how sensitive the app is.
  5. Issue a new session ID after login and after any privilege change, such as a role switch or password change.
  6. Require users to sign in again after password or email changes and account recovery, and give them a way to see and sign out of their other active sessions.
  7. On logout, send Clear-Site-Data, and mark pages with sensitive data Cache-Control: no-store. Keep session cookies Secure, HttpOnly and SameSite.

Why it matters

MITRE tracks this as CWE-1464 (Improper Session Invalidation), added in CWE 5.0 on October 28, 2026, which replaces the deprecated CWE-613. Its child entries cover sessions that survive logout (CWE-1465) and sessions that survive a credential change (CWE-1466). MITRE's mitigation is to invalidate sessions on the server for all security-relevant events and not rely on the client to delete them, and its detection advice is to test that a session can no longer be used afterward. OWASP's Session Management Cheat Sheet says expiration must be enforced on the server, that deleting a cookie in the browser doesn't invalidate a copy someone else holds, and that apps should use both idle and absolute timeouts. It notes common idle timeouts of 2 to 5 minutes for high-value apps and 15 to 30 minutes for low-risk ones, and absolute timeouts of 4 to 8 hours for apps used through a full office day. It also warns that browser-close events can't reliably log users out.

Sources

MITRE CWE-1464: Improper Session Invalidation — https://cwe.mitre.org/data/definitions/1464.html

OWASP Cheat Sheet Series: Session Management Cheat Sheet — https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html

Checked at the source on October 30, 2026.

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.