skip to content

Sign-out destroys the stored session record — what else must end with it, and which item do teams forget?

level: seniorimportance: must knowfreq 66%

answer

  1. a teardown, not a redirect
  2. the record is one line, not the list
  3. anything that can mint a new session
  4. the persistent-login cookie signs you back in
  5. destroy before writing the response

basics

~20 s

Destroying the record is one item on a list. A persistent-login cookie, the anti-forgery token, credentials obtained downstream, connections authenticated at handshake and already-rendered pages all outlive it. The forgotten one is whatever can create a new session unaided.

solid answer

~50 s

Sign-out is a teardown with a checklist, and the stored record is only its first line. Also ending: any per-instance copy of that record held in front of the shared tier, the reference in the client's cookie jar, the anti-forgery token bound to the destroyed session, a long-lived connection that was authenticated once at its handshake, and any credential the server obtained downstream while acting for that user. The item teams forget is the **persistent-login cookie** — the "keep me signed in on this console" credential — because every other missed item merely leaves data the user has already seen, while that one is silently exchanged for a **brand-new authenticated session** on the very next request. Ordering matters too: destroy the record before writing the response, or a concurrent request slipping through the gap authenticates against a session the user believes is gone.

code

http · 8 lines
http
POST /session/sign-out HTTP/1.1
Host: invigilation.example.edu
Cookie: sid=9f3c1a7e42b8; console_persist=5d0b71ac93fe
Content-Length: 0

HTTP/1.1 204 No Content
Set-Cookie: sid=; Path=/; Max-Age=0; HttpOnly; Secure
Set-Cookie: console_persist=; Path=/; Max-Age=0; HttpOnly; Secure

go deeper

for a junior

Recall that signing out has to delete something on the server, not just move the browser to a sign-in page, and that a 'keep me signed in' credential is a second thing that has to go.

for a middle

Explain the list and why each item survives on its own: separate stores, separate lifetimes, separate code paths. Say which of them can produce a new authenticated session and which merely leaves old data visible.

for a senior

Show the ordering — destroy before responding, so a request in flight cannot slip through — and name the test that catches the forgotten item: replay the persistent-login credential alone and require a rejection.

for a principal

State the guarantee the system actually offers rather than the one people assume: no new request authenticates and nothing left behind can mint a session. Then design the screens and the audit trail around that boundary.

## Sign-out is a teardown, not a redirect "Logout did not log out" is the oldest complaint in this subject, and almost every instance of it is the same root cause: the code treated sign-out as a navigation — clear the reference, send the user to the sign-in page — when it is a teardown of everything that was created under one authentication. The stored record is the first item on that list and the easiest one. The value of the question in an interview is not the list itself but knowing which line gets skipped and why. The frame that makes the list memorable: **anything that can act as that user after the button is pressed must be ended, and anything that can *create* a new session for that user must be ended first.** ## The checklist | Item | Why it outlives the record | What it costs if skipped | |---|---|---| | The stored session record | nothing deletes it but you | the reference keeps authenticating | | A per-instance copy of that record | a local cache in front of the shared tier has its own lifetime | one server keeps honouring a destroyed session | | The reference in the client's cookie jar | the client holds it until told otherwise | a value that still gets presented, and is readable on a shared console | | A persistent-login cookie | it is a separate credential, by design | the next request silently creates a **new** authenticated session | | The anti-forgery token for that session | it was issued against a session that is now gone | confusing failures for the next user of the console | | A connection authenticated at its handshake | it was checked once, at the start | it keeps delivering data after sign-out | | Credentials obtained downstream for that user | they live in their own store with their own lifetimes | the server keeps acting for a signed-out user | | Pages already rendered to the client | they were delivered before the button was pressed | previously-shown data is re-displayable | The last two rows are deliberately shallow here, because each is a mechanism in its own right — revoking stored downstream credentials, and how a client or an intermediary holds an already-delivered authenticated page, are separate subjects with their own rules. What belongs on *this* checklist is that neither of them ends by itself when you delete a row. ## The item teams forget, and why It is the **persistent-login cookie**. Two reasons it is missed and one reason it matters more than the rest: - It is missed because it was built by a different change, for a different purpose — convenience — and often lives in a different store from the session record, so a sign-out written against the session tier simply never touches it. - It is missed because testing sign-out usually means clicking sign-out in a browser that then sends *both* references on the next request, gets rejected on the session one, and looks correct. - It matters more because of asymmetry: a stale rendered page discloses data the user already saw, while a surviving long-lived credential is **exchanged for a fresh authenticated session** on the very next request. The user pressed sign-out and is signed in again, with a new identifier and a full set of clocks. On a console that several people use across a shift this is the whole point of the button. The test that catches it is blunt: sign out, throw away the session reference, replay only the persistent-login credential against an authenticated endpoint, and require a rejection. ## Ordering: destroy before you respond The teardown happens **before** the response is written, not after it. The window between "we sent the redirect" and "we deleted the row" is small and entirely real — a request already in flight from another tab, or a background poll on the console, lands inside it and authenticates successfully against a session the user believes is over. Do it in this order: 1. Destroy the stored record, and invalidate any local copy of it in front of the shared tier. 2. Revoke the separate credentials created under that session, the persistent-login cookie first. 3. Close the connections that were authenticated at handshake time. 4. Write the response, clearing the client's references as a courtesy. Step 4 is last and is the weakest step in the list: clearing a client-side copy stops a well-behaved client re-presenting a value, and does nothing at all about a value that has already been copied elsewhere. That is why the deletions above it are the ones that matter. ## What sign-out honestly cannot reach An answer that claims sign-out reverses everything is wrong, and saying so is part of the answer. Bytes already delivered to a client have been delivered. A stateless credential handed to another system keeps validating until its own lifetime ends unless that system is told otherwise. What sign-out does guarantee is narrower and worth stating plainly: **no new request authenticates, and nothing left behind can mint a session.** Design the surfaces on the console with that guarantee in mind rather than pretending to a stronger one.

  • Which single item on the list would you test first, and how?
    The persistent-login cookie. Sign out, discard the session reference entirely, then replay only that credential against an authenticated endpoint. A success means sign-out was a redirect: the credential was exchanged for a brand-new session. Testing through a browser hides this, because the browser keeps sending both references and the rejected session reference makes the result look correct.
  • Sign-out has run and the next person on the shared console presses Back. What is honestly in your control?
    No new request succeeds, because the record is gone and nothing left behind can mint a session. A page already delivered can still be re-displayed from the client's own history, and how a client or an intermediary retains a delivered authenticated response is a separate layer with its own controls. Treat what was rendered as already disclosed and design the screens accordingly.
  • Does an idle timeout do the same job as sign-out?
    It removes the same record, and nothing else on the list. It also fires at a moment nobody chose, so it cannot be the mechanism a user relies on when handing a console to the next shift. Expiry bounds the damage of a forgotten session; sign-out is the deliberate teardown, and only one of them is a checklist.

Handing back the key to a lab at the end of a shift ends your access — unless the badge that lets you request a spare key at the desk is still in your wallet. Deleting the session record is the key; the persistent-login cookie is the badge, and it is the one nobody asks for.

saying these in an interview costs you the question

  • Clears the browser's cookie and calls that sign-out.
  • Leaves the persistent-login credential in place after signing out.
  • Assumes a connection authenticated at handshake drops with the record.
  • Deletes the record after responding, leaving a race window open.
  • Thinks expiring the record covers everything else on the list.
  • Claims sign-out retracts pages already delivered to the client.