DEV Community

Cover image for Session Storage vs Local Storage vs Cookies
Kyle Foo
Kyle Foo

Posted on • Updated on

Session Storage vs Local Storage vs Cookies

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 for list of APIs

Top comments (3)

w6 profile image

Great table, I will definitely bookmark this!

rexyandrian profile image
Rexy Andriansyah

Which one the most secure on browser storages ?

kylefoo profile image
Kyle Foo • Edited

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.