Skip to content
Docs
Get RestroPress

Filter

rpress_start_session

Updated
On this page

Filters whether a PHP session should be started for the current request.

Applied in RPRESS_Session::should_start_session(). The default is true, except for blacklisted URIs, feeds, the admin (apart from admin-ajax.php) and requests containing wp_scrape_key. It is used by maybe_start_session().

Parameters#

ParameterTypeDescription
$start_sessionboolWhether to start the session.

Return value#

bool. True to start the session.

Example#

function my_start_session( $start_session ) {
	// Do not start sessions for REST API requests.
	if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
		return false;
	}
	return $start_session;
}
add_filter( 'rpress_start_session', 'my_start_session' );

Source#

Applied in:

  • includes/class-rpress-session.php (line 292), in RPRESS_Session::should_start_session()

See also#

Was this page helpful?