According to MDN it is suppose to be more secure than cookies for storing persistent data on the client.
However, checking the localStorage
of facebook.com
, twitter.com
, and linkedin.com
I can see that it is not being used.
Oddly, linkedin
does have the key ( in localStorage
) 8df
when logged in , but trying to access it throws an error.
Cookies are intended to be read by the server, whereas localStorage can only be read by the browser. Thus, cookies are restricted to small data volumes, while localStorage can store more data.
The data stored in local storage is only available on the client-side. Unlike cookies, it is not sent to the server on each request. The major difference between cookies and local storage is the amount of data that can be stored.
Limitations & considerations to use local storage: It is not secure, can be accessed by browser developer tools, so don't use it to store sensitive data. It can be cleared by the user when he/she clears all browser history. It can only store string data.
If you need to store data that is accessible for both the server and the client, use cookies. Otherwise, use local storage. If you need to store larger data, use local storage. If you need to store data that does not expire, use local storage.
My guess (hopes this qualifies has an answer)
Web Storage is compatible with most common browsers: http://caniuse.com/namevalue-storage .
For things that don't need to transit with session: what probably happens is that cookies is most commonly known and easy to use. There are lots of companies with average skilled ppl, who will run away when confronted with things out of their confort zone.
Edit after Python Fanboy's answer (+1 from me): read his answer.
localStorage
has this drawback which cookies doesn't have: it's stored values aren't sent automatically with all HTTP requests so without more implementation Your server won't know what's stored in browser's localStorage
.
localStorage
is supported in IE since IE8.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With