Repaso
Español
Frontend & WebIntermediateFE-22

Which storage is sent to the server automatically with every matching request?

Options

  1. localStorage
  2. sessionStorage
  3. Cookies (Correct option)
  4. IndexedDB

Answer

Cookies

Why

Cookies are attached by the browser to every request to their domain, which is why sessions use them. They are small (about 4 KB).

localStorage (permanent) and sessionStorage (per tab) stay in the browser; JavaScript must read them and send them explicitly. Any script on the page can read them, so they are risky for auth tokens.

IndexedDB is a larger in-browser database.

Remember

Only cookies travel automatically with requests.

Key terms

Practice this question in Repaso