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
Top comments (3)
Great table, I will definitely bookmark this!
Which one the most secure on browser storages ?
don't think any of them provide security since all of them on the client side, unless u encrypt your data before storing them, have your application (server-side?) to decrypt every time you wanna access them.