Definition
Cookie
Example
Staying logged in after closing a tab often depends on cookies.
Read more
- What are cookies on websites?
A cookie is a small piece of text that a website asks your browser to store and send back on later visits. Cookies keep you logged in, remember your basket and settings, and measure traffic. Third-party cookies, set by companies other than the site you are on, can also be used to follow you across many sites for advertising.
- Cookies vs local storage
Cookies are small values (about 4 KB each) that the browser sends to the server automatically with matching requests, and they can be hidden from JavaScript with HttpOnly. Local storage holds around 5 MiB of strings per origin, is never sent automatically, and is always readable by any script on the page. Use cookies for sessions, localStorage for client-only state.