Somebody already asked that question on SO: http://stackoverflow.com/questions/3220660/local-storage-vs-cookies ,and there is a very good answer:
Cookies and local storage serve different purposes. Cookies are primarily for reading server-side, local storage can only be read client-side. So the question is, in your app, who needs this data — the client or the server?
If it's your server, local storage isn't so useful because you'd have to forward the data along somehow (with Ajax or hidden form fields or something). This might be okay if the server only needs a small subset of the total data for each request.
You'll want to leave your session cookie as a cookie either way though.
As per the technical difference, and also my understanding:
- Apart from being an old way of saving data, Cookies give you a limit of 4096 bytes (4095, actually) - its per cookie. Local Storage is as big as 5MB per domain - SO Question also mentions it
localStorageis an implementation of the
Why I mention about it? For two reasons:
a) I use this blog as my notepad, that I sometimes visit
b) this question have a great "interview question" potential