Session Storage vs Local Storage vs Cookies
Kyle Foo
Posted on December 22, 2020
Wondering which browser storages best fit your use case? Here's a brief comparison to help you with making decision:
Session Storage | Local Storage | Cookies | |
---|---|---|---|
Storage Size | 5MB on browser | 10MB on browser | 4kb on browser or server |
HTML support | HTML 5 | HTML 5 | HTML 4&5 |
Accessibility | Own tab only | Across tab & windows | Across tab & windows |
Expiry | Expires on tab close | No expiration | *Configurable |
Updatable via | *Web Browser API | *Web Browser API | Server Side Request or *Web Browser API |
*Configurable Expiry: When a server responds to a browser request, it can send down a Set-Cookie header with one or many cookies, ex:
Set-Cookie: user_id=5; Expires=Fri, 5 Oct 2018 14:28:00 GMT; Secure; HttpOnly, remember_me=true
*Web Browser API: see https://developer.mozilla.org/en-US/docs/Web/API for list of APIs
💖 💪 🙅 🚩
Kyle Foo
Posted on December 22, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.