/simple-storage

This simple JavaScript library makes using Local and Session storage easier. It has no dependencies and is only 2kb minified.

Primary LanguageJavaScriptApache License 2.0Apache-2.0

simple-storage

This simple JavaScript library makes using Local and Session storage easier. In addition, while local storage has no expiration, this package has functions that allow you to set an expiration.

It has no dependencies and is only 2kb minified. Web storage is supported in Internet Explorer 8+, Firefox, Opera, Chrome, and Safari.

Available Functions

  • saveLocalStorage(key, content, expiration) - saves to the local storage.
    Parameters
    • key: the unique key for content
    • content: the content to save
    • expiration: (OPTIONAL) if set, the seconds until the storage should expire
  • saveSessionStorage(key, content) - saves to the session storage. Session storage expires with the browser window.
    Parameters
    • key: the unique key for content
    • content: the content to save
  • getLocalStorage(key) - gets an item from local storage
    Parameters
    • key: the unique key to find the content
  • getSessionStorage(key) - gets an item from session storage
    Parameters
    • key: the unique key to find the content
  • deleteLocalStorageValue(key) - removes the content stored for this key
    Parameters
    • key: the unique key to find and remove content for
  • deleteSessionStorageValue(key) - removes the content stored for this key
    Parameters
    • key: the unique key to find and remove content for
  • clearLocalStorage() - clears ALL content in local storage for this domain
  • clearSessionStorage() - clears ALL content in session storage for this domain