Local Storage vs Cookies

To reduce load times on our websites, we always cache some item in cookies and local storage. In this article some of differences between “Local Storage vs Cookies” is described.

Both Cookies and local storage serve difference purposes.

Choosing from these two

Cookies are primarily for reading server-side, local storage can only be read client-side.

So choosing from these two location to store data for our app, one question comes that, who needs this data : the client or the server?

If it’s our client (like JavaScript), then we can store all data in local storage.

If it’s our server need data, local storage isn’t so useful because we have to forward the data with each request by somehow (with Ajax or hidden form fields or something).

Diffrence

LocalStorage stays on the client, while cookies are sent with the HTTP header.

Continue reading