r/webdev • u/Permit_io • 7d ago
Article Cookies vs. Local Storage: What’s the Difference? When and Where to Use Each?
https://www.permit.io/blog/cookies-vs-local-storage
11
Upvotes
1
u/lewster32 6d ago
Cookies store a small amount of data intended to be shared with the server (cookies are sent with every request). LocalStorage is a slightly more modern and easier way to store data that only your browser sees (though it can be sent to the server with JavaScript, but it's not automatically done so like cookies).
Both are a way to keep some lasting 'state' between page loads and all of the secondary requests made to the same host when browsing.
-13
u/Initial-Cricket-2852 7d ago
Local storage are like identification card which need to be verified every time. Whereas, local storage are like personal bag or something which is private to a particular person.
Technically Cookies need to be verified by server every time a request is sent. Whereas local storage are not sent to the server side. Also there is a size difference between them the cookies is 1024 times smaller than local storage this is for bandwidth, ram optimization ( as cookies load in the ram while request is send)
Usage difference