Case DDA2BB · Web AppSec · L2 Practitioner

Secure Session Management

Practise as: InterviewLevel: L2 Practitioner

Interview questionHow would you design session management for a new web app? What settings would you insist on?

  1. 01 Answer
  2. 02 Example
  3. 03 Trade-offs
What a strong answer covers

Try it out loud first. Then check yourself:

  1. Server-generated session ID from a CSPRNG with high entropy, opaque and meaningless; never put it in URLs
  2. Cookie flags: Secure, HttpOnly, SameSite=Lax or Strict, narrow Path, and the __Host- prefix to block subdomain overwrite
  3. Rotate the ID on login and privilege change to stop session fixation; invalidate server-side on logout and password change
  4. Idle and absolute timeouts sized to risk; re-authenticate for sensitive actions like changing email or MFA
  5. Trade-off: stateful sessions revoke instantly; stateless JWTs scale easily but need short expiry plus refresh to revoke

If the interviewer pushes back

  • A user reports being logged in on a device they do not recognise. What does your design let them, and you, do about it?

Go deeper

More Web AppSec cards

All Web AppSec cards →

cardosec draws a security topic and gives you a clock: explain it out loud with no notes, then see what you covered and what you missed. Free during early access.

Reviewed 2026-10-09