Q1-> What are the advantage of SessionStorage/LocalStorage over Cookie ?
Q2-> A Value stored by xyz site can be viewed or edited by any other site or the user ?
1) Session Storage and Local Storage allow for a greater capacity (currently 5mb with most browsers), and are not sent back to the server for every HTTP request (HTML, images, JavaScript, CSS, etc) - reducing the amount of traffic between between client and server (saving you $dosh).
2) Local / Session Storage are both restricted to the domain setting/getting the values, so if you use localStorage.set('key', 'val')
on www.domain1.com, you cannot access that data using localStorage.get('key')
on www.domain2.com. Bear in mind the restriction also applies to domains and subdomains - i.e. you cannot access www.domain1.com local/session storage from sub.domain1.com either.
Update from @josh3736: users, however, have full access to the raw local and session storage. This is how users are currently able to unlock all levels on the web version of Angry Birds: http://wesbos.com/all-levels-html5-angry-birds/ - to reiterate Josh, never trust data at the client tier.
More details here: http://diveinto.html5doctor.com/storage.html
Another advantage of using Session Storage its performance in using it. Especially for large data (100kb,etc). Simple cookies would have to be a part of each request to the server. So you won't get this stored data to the server by simple means, but I can libe with that.
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