Sessions that stay valid after logout, password change or timeout

Last updated November 9, 2026
Steps
- 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.
- Repeat the test after a password change, an email change and an admin disabling the account. Old sessions should stop working in each case.
- End sessions on the server at logout: delete the session record or revoke the token, not just the cookie.
- Enforce an idle timeout and an absolute timeout on the server, sized to how sensitive the app is.
- Issue a new session ID after login and after any privilege change, such as a role switch or password change.
- 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.
- 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
- JWTs or session tokens stored in localStorage
- Password reset flows that leak accounts or trust the Host header
- Tokens and IDs generated with Math.random()
- Cookie-based login with no CSRF protection on state-changing requests
- Auth checked only in Next.js middleware (proxy)
- IDOR in vibe-coded apps: changing an ID in the URL to see someone else's data
- Session cookies missing Secure, HttpOnly or SameSite
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 StorenTechVibe 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.