Skip to content
Docs
Get RestroPress

Filter

wp_session_expiration

Updated
On this page

Filters the session lifetime, in seconds, of the bundled WP_Session library.

Applied when a session is created or its expiration is set. The result is added to the current time to get the cookie and data expiration. RestroPress hooks this filter at priority 99999 and returns 43200 seconds (30 * 60 * 24), so a callback must run later than that priority to override it.

Parameters#

ParameterTypeDescription
$expirationintLifetime in seconds. The default is 30 * 60.

Return value#

int. Number of seconds.

Example#

function my_session_expiration( $expiration ) {
	return DAY_IN_SECONDS;
}
add_filter( 'wp_session_expiration', 'my_session_expiration', 100000 );

Notes#

A second bundled copy of the library passes 24 * 60 as the default instead of 30 * 60. The value is read in WP_Session::set_expiration in the copy that RestroPress loads.

Source#

Applied in:

  • includes/libraries/class-wp-session.php (line 110), in WP_Session::set_expiration()
  • includes/libraries/wp_session/class-wp-session.php (line 71), in WP_Session::__construct()

See also#

Was this page helpful?