In the battle of local storage vs cookies one would justifiably argue that they both have the same functionality. So here we will take a little of your to debunk what each of them are.
The first thing to note is that cookies and local storage serve different purposes. The major difference here is that local storage can only read client-side data. Cookies on the other hand are primarily used for reading server-side data. That is the simple explanation as the what they are. To cement the functions, let’s take a deeper look.
When to use Local Storage vs Cookies
The deciding factor here is whether the client of the server needs this data. If your server needs it as has traditionally been then local storage will not be that useful and cookies is the way to go as this data from cookies can be passed on to the server.
If your client needs to read the data and the server has no need for it, you can save bandwidth by storing data in the local storage. Local storage also stores far more data that cookies so that might also be useful.
From a technical standpoint there is also a huge difference in the specifications of how much data you can store in local storage. Cookies have a limit of 4KB (4096 bytes or 4095 bytes) per cookie. As for local storage you have a larger capacity of 5MB per domain.
One thing to note with local storage vs cookies is that local storage does not supported anything before Chrome 4, Firefox 3.5, IE 8, Opera 10.5, Safari 4, iOS 2.0 and Android 2.0.
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.