/** function body that test if storage is available* returns true if localStorage is available and false if it's not*/function lsTest(){var test = 'test';try {localStorage.setItem(test, test);localStorage.removeItem(test);return true;} catch(e) {return false;}}
/** execute Test and run our custom script*/if(lsTest()) {// window.sessionStorage.setItem(name, 1); // session and storage methods are very similarwindow.localStorage.setItem(name, 1);console.log('localStorage where used'); // log} else {document.cookie="name=1; expires=Mon, 28 Mar 2016 12:00:00 UTC";console.log('Cookie where used'); // log}