{hero}

stateDuration

Since: DataTables 1.10

Saved state validity duration.

Description

Duration for which the saved state information is considered valid. After this period has elapsed the state will be returned to the default.

This option is also used to indicate to DataTables if localStorage or sessionStorage should be used for storing the table's state. When set to -1 sessionStorage will be used, while for 0 or greater localStorage will be used.

The difference between the two storage APIs is that sessionStorage retains data only for the current session (i..e the current browser window). For more information on these two HTML APIs please refer to the Mozilla Storage documentation.

Please note that the value is given in seconds. The value 0 is a special value as it indicates that the state can be stored and retrieved indefinitely with no time limit.

Type

This option can be given in the following type(s):

Default

  • Value: 7200

Examples

Set state duration to 1 day:

new DataTable('#myTable', {
	stateSave: true,
	stateDuration: 60 * 60 * 24
});

Use sessionStorage:

new DataTable('#myTable', {
	stateSave: true,
	stateDuration: -1
});

Related

The following options are directly related and may also be useful in your application development.