DIfference between Local storage and cookies.

Posted by Sahoo under Interview Questions on 5/7/2012 | Points: 10 | Views : 23017 | Status : [Member] | Replies : 2

Can any body please give me detail difference between local storage(html5) and cookies.What advantages of using cookies or local storage over each other and when to use what.

Many many THANKS in advance.


Posted by: Sheonarayan on: 5/7/2012 [Administrator] HonoraryPlatinum | Points: 25

Hi Sahoo,

Below is some difference I could recall between localStorage and Cookies at the time of writing

Local storage
- Local storage stores the data in the form of key and value
- The data is stored for longer duration and remains in the browser unless user delete it explicitly, it remains even after computer restart
- No way to specify the time out period as the Cookies have
- Good to store large amount of data, up to 4MB
- Good to create offline application that runs in the client machine (browser)
- Easy to work with the JavaScript
- Local storage data is not sent to the server on every request (HTTP header) as it is purely at the client side

- Good for small amount of data
- Difficult to work with JavaScript
- All data is transferred to and from server, so bandwidth is consumed on every request
- Can specify timeout period so that cookies data are removed from browser

Hope this helps.


Sheo Narayan

Sahoo, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response