applyFilters( “set_data_expire” )

  1. Home
  2. Knowledge Base
  3. Codex
  4. JS API
  5. JS Filters
  6. applyFilters( “set_data_expire” )
DiviArea.applyFilters( "set_data_expire", lifespan, key, value );
DiviArea.applyFilters( "set_data_expire_{key}", lifespan, key, value );

Filters the lifespan of a local data entry. This will directly influence the Cookie expiration date or the internal expiration timestamp of localStorage entries.

The {key} part in the hook name is the sanitized variable-name (all lower case, dashes changed to underscores).

Params

lifespan
(int) Lifespan of the item, in minutes.
key
(string) Name of the entry. This will be part of the Cookie name or the localStorage object key.
value
(string) The value which will be saved to the Cookie or localStorage.

Source

This filter is called inside DiviArea.Utils.setLocalData().

Examples

// Disable local data
DiviArea.addFilter( 'set_data_expire', function( lifespan, key, value ) {
    return 0;
});

Notes

The setLocalData() method will decide, whether to write a Cookie or to save data to the localStorage instead.

When this filter returns a value lower than 1, then no entry is saved in the localStorage (and no Cookie will be created)

Was this article helpful?

Related Articles