dictionary.setStorage()

dictionary.setStorage(storage,[fallback])
Returns: null

Description:  Sets the dictionary engine storage types for its global scope.

  • storage – keyword for the storage used
  • fallback – Boolean – optional – use cookie storage as fallback if using required storage is not supported.

Current supported storage engines are:

  • local – Uses browser local storage
  • session – Uses browser session storage
  • cookies – Uses browser cookies , persistent across session
  • cookiesSession – Uses browser cookies , only for current session session

Setting a storage will also retrieve all data from the storage on the global scope. As a example if the global scope is empty but the dictionary data has been saved in the local storage previously:

var testDictionary = klevu.dictionary("test");
testDictionary.getGlobal(); // {}
testDictionary.setStorage("local", true); 
testDictionary.getGlobal(); // {test: "test"}

Leave a Reply