This project is not covered by Drupal’s security advisory policy.

Provides a javascript api for storing user data in one or more of the following locations:

  • Cookies
  • Local storage
  • Session storage
  • Internal(Drupal) database
  • External database

This is an api module. It is useless on its own. Only install this module if other modules you are using requires it.

The module is useful for sites that exists behind a web-cache. With this module a cached page can store user data to an external service.

A module that uses this module for storing user data will be able to use external services for storing user data, but will also be able to work well on sites that don't use external services for storing user-data.

Examples:

new JStorage('my_namespace', function (storage) {
  storage.set('numbers', [1, 2, 3]);
  storage.get('numbers'); //will return the array above 
  storage.del('numbers'); 

  // Advanced:
  storage.set('numbers', [1, 2, 3, 4], {
    profile: true, // Save to database
    browser: false // Do not save in cookies, localStorage or sessionStorage
  });

  storage.set('numbers', [1, 2, 3, 5], {
    profile: true, // Save to database
    browser: true, // Also save in browser
    session: true, // Save only for this session
    group: 'math' // Group these values with other math values to avoid creating too many cookies...
  });
});

Note about 1.0-beta6:
The new external storage object(the one which is sent as a parameter to the callback for the function you specify in the admin settings, also known as propertyListObject) need to implement the following functions:

.getDisplayName(); // return mixed Username if logged in, otherwise false.
.get(name); // return string Value for given name.
.set(name, value); // Currently no return.
.unset(name); // Currently no return.

Sponsored

The project is financed by the Norwegian Digital Learning Arena(NDLA), and developed by Amendor(norwegian only).

Project information

Releases