LEARN. PRACTICE. EXPLAIN.
Learning paths & interview practiceP
← Build a login system
BUILD → VERIFY → EXPLAIN · STEP 5 OF 6

Handle expiry and logout

End authority on the server, including when an old cookie is replayed.

UNDERSTAND

Bring these concepts with you

BUILD

Your implementation

  1. Implement logout so repeating it is harmless. Delete the session record identified by the token hash.
  2. Keep the provided HTTP logout adapter: it revokes server state and sends a clearing cookie using the same name and path.
  3. Test immediately before expiry and exactly at expiry with the injected clock. This lab has an absolute 60-second lifetime and no refresh-token flow.
function logout(token) {
  // Delete server state; unknown tokens should be harmless.
}
Need a hint?
  • Clearing the browser cookie alone does not revoke a copied token.
  • Use now() >= expiresAt to reject the exact expiry boundary. Logging out one session should not accidentally remove another.

Saved on this device · 0 / 6000 · Do not include passwords or private data.

VERIFY

Acceptance checks

From the folder containing your downloaded files, run:

node checks.mjs ./starter.mjs 5

This runs checks up to this step. Earlier steps must work first. Mark each result only after checking your implementation; the website does not run or grade it.

Record your attempt to enable the checklist and reference comparison.

Compare with the reference

Attempt the step first, then compare decisions and behavior. There can be more than one correct implementation.

EXPLAIN

Your interviewer asks

How would you implement logout from every device? What changes if the access credential is a signed JWT?

Say your answer aloud, then record the trade-offs and evidence in your notes above.

LOCAL VOICE REHEARSAL

Rehearse your step walkthrough aloud

Target pacing: 02:00 · Stays in this browser only; never uploaded.

00:00/ 02:00
AlifBay Prep