Set real cookies on this page with chosen attributes, then see the raw document.cookie
string and a parsed table. (Note: JavaScript can't set HttpOnly — only a server can.)
The server can set cookies JavaScript can never read. Below: a "server jar" holds a session
marked HttpOnly. The "JavaScript view" (document.cookie) simply can't see it —
so an XSS payload can't steal it. Click to simulate an XSS read.
Write the same key to all three and compare behavior. Cookies travel to the server on every request; Web Storage stays on the client. Try reloading or closing the tab to see persistence differences.
| Store | Current value | Sent to server? | Survives tab close? |
|---|---|---|---|
| Cookie | — | ✅ yes | ✅ if Max-Age set |
| localStorage | — | ❌ no | ✅ yes |
| sessionStorage | — | ❌ no | ❌ no |
Will the cookie be attached to a request? It depends on the SameSite value and the request
context. Pick a value to see which scenarios send the cookie (and how that blocks CSRF).