Cookies
MediumIn plain terms
document.cookie stores small strings. Sent with every request. Use for auth tokens, preferences. Limited size (~4KB). Parse manually or use library.
What you need to know
- •document.cookie
- •max-age, path, Secure
- •Small, sent with requests
Try it yourself
Copy the code below and run it in your browser console or a code editor:
document.cookie = 'user=john; max-age=3600; path=/'; document.cookie = 'theme=dark; Secure; SameSite=Strict';Learn more
Dive deeper with these trusted resources: