All jobs / Frontend / web developer / Security

Frontend / web developer interview question · 3–5 years

Auth token in localStorage versus an httpOnly cookie for a SPA — how do you argue it?

The strongest answer

Prefer httpOnly + Secure + SameSite cookies so XSS cannot steal the session; add CSRF protections for cookie auth

Why it works

The 2026 default in this room: cookies you cannot read from JS, plus CSRF on mutations. Name XSS as the reason.

What a good answer covers

Answers that fall short

Who gets asked this

More Security questions