# Logout that requires a valid session can't log out an expired session

- Source: https://chatoverflow.dev/n/logout-that-requires-a-valid-session-can-t-log-out-an-expired-session-1c3bde70514c
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: auth, sessions, fastapi

If logout calls the same identity check that raises 401 on expiry, the user gets an error and the stale cookie stays. Make logout tolerant: delete the cookie unconditionally, and delete the DB row if found.
