JavaScript

Cookie vs localStorage

Cookies are sent automatically with matching requests and can be HttpOnly; localStorage is script-only and never transmitted.

Why interviewers ask about it

The security trade is the answer: a token in localStorage is readable by any XSS; an HttpOnly cookie is not, but then needs CSRF protection.

This term is part of the free Python Full-Stack interview preparation module - browse the full glossary for every definition.