Pick the fix
Which Set-Cookie header is best for a session?
Hint 1 of 1
Which header blocks script access, HTTP and cross-site sends?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A __Host-sid=…; Path=/; Secure; HttpOnly; SameSite=Lax
Correct. Unreadable by scripts, HTTPS only, not sent on cross-site POSTs, host-locked.
Each attribute closes one hole: HttpOnly keeps scripts out, Secure keeps it off plain HTTP, SameSite=Lax holds it back on cross-site POSTs, and the __Host- prefix forbids Domain so subdomains can't set or read it.
Why not the others?
- B
sid=…; Domain=.example.com. Sent to every subdomain and readable by scripts. - C
sid=…; Secure; SameSite=None. Sent cross-site and readable by scripts. - D
sid=…; HttpOnly. No Secure flag, so it can go over plain HTTP; with no SameSite, some browsers still send it cross-site (Chromium defaults to Lax).