applyFilters( "set_data_expire", lifespan, key, value );
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 dynamic part of the filter name is the sanitized entry name. See DiviArea.Utils.sanitizeHookName()
for details.
Params
lifespan
- The lifespan of the item, in minutes.
key
- Name of the entry. This will be part of the Cookie name or the localStorage object key.
value
- The value which will be saved to the Cookie or localStorage.
Returns
The filtered lifespan in minutes (integer)
Examples
// Disable local data
DiviArea.addFilter( 'set_data_expire', function( lifespan, key, value ) {
return 0;
});
Notes
The DiviArea.Utils.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)