Skip to content

Instantly share code, notes, and snippets.

@Saucy
Created December 1, 2015 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saucy/ec844e787093743c1e70 to your computer and use it in GitHub Desktop.
Save Saucy/ec844e787093743c1e70 to your computer and use it in GitHub Desktop.
Poor JavaScript example of LocalStorage
var CanDownload = localStorage.getItem('CanDownload');
// If localStorage variable 'CanDownload' isn't set yet, set it to true
if (CanDownload == null) {
localStorage.setItem('CanDownload', true);
}
// function called when button is clicked
// changes CanDownload status to false
function ChangeButton () {
localStorage.setItem('CanDownload', false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment