Skip to content
Docs
Get RestroPress

Action

wp_session_start

Updated
On this page

Fires after the bundled WP_Session library has started or resumed a session.

Runs from wp_session_start, which is attached to plugins_loaded. At this point the WP_Session instance exists and the session cookie has been read or created. It takes no arguments.

Example#

function my_on_session_start() {
	$session = WP_Session::get_instance();
	if ( ! isset( $session['my_first_seen'] ) ) {
		$session['my_first_seen'] = time();
	}
}
add_action( 'wp_session_start', 'my_on_session_start' );

Notes#

Only fires when the WP_Session library is in use, not when PHP sessions are configured.

Source#

Fired from:

  • includes/libraries/wp-session.php (line 69), in wp_session_start()
  • includes/libraries/wp_session/wp-session.php (line 71), in wp_session_start()

See also#

Was this page helpful?