Web Storage
+Things you should know
+How to detect WebStorage
+Here is some example code to detect if you have LocalStorage support
+
+function checkLocalStoreageSupport () {
+ if (localStorage) {
+ return "Local Storage: Supported";
+ } else {
+ return "Local Storage: Unsupported";
+ }
+}
+
+
+ Setting and getting values from WebStorage
+Here is some example code to set and get values from Local Storage. Values can be any string INCLUDING JSON!!!
+
+//Set the value of a key
+localStorage.lastname="Smith";
+localStorage["lastname"] ="Smith";
+localStorage.setItem("lastname", "Smith");
+
+//Get the value of a key
+var lastname = localStorage.lastname;
+var lastname = localStorage["lastname"]
+var lastname = localStorage.getItem("lastname")
+
+//Storing an object
+localStorage.setItem('user', JSON.stringify({user: 'john', id: 10}));
+var user = JSON.parse(localStorage.getItem('user'));
+
+
+ WebStorage vs other offline storage
+WebStorage is a simple key value store in the browser which is supported across all new browsers. For a more powerful database, Web SQL is used which is an implementation of sqlite right in the browser, however cannot be used with Firefox and Internet explorer. Chrome, Firefox and Internet Explorer also support IndexedDB, another local storage database.
+ +Using LocalStorage with older browser or multiplatform
+One approach is to use a polyfill library to backport the localStorage interface. One example would be Store.js
+Another approach would be to use a multiplatform library that has a new interface on top of multiple sotrage platforms. Some examples could be:
+-
+
- Lawnchair +
- Persistence.js +
- BackBone +