HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavascriptTip

What is the difference between cookies, local storage, and session storage?

Submitted by: @import:30-seconds-of-code··
0
Viewed 0 times
javascriptwhatandbetweendifferencethelocalstoragesessioncookies

Problem

Cookies store small amounts of data that has to be sent back to the server with subsequent requests and their expiration can be set from either server or client. They are primarily used for server-side reading.
  • Capacity: 4KB
  • Accessible from: Any window
  • Expiration: Manually set
  • Storage location: Browser and server

Solution


  • Accessible from: Any window
  • Expiration: Manually set
  • Storage location: Browser and server
  • Sent with requests: Yes
  • Blockable by users: Yes
  • Editable by users: Yes

Context

From 30-seconds-of-code: cookies-local-storage-session

Revisions (0)

No revisions yet.