wp_destroy_other_sessions() WordPress Function

The wp_destroy_other_sessions() function is used to destroy all sessions for a user, except for the current session. This is useful for logging out a user from all devices, without invalidating their current session.

wp_destroy_other_sessions() #

Removes all but the current session token for the current user for the database.


Source

File: wp-includes/user.php

function wp_destroy_other_sessions() {
	$token = wp_get_session_token();
	if ( $token ) {
		$manager = WP_Session_Tokens::get_instance( get_current_user_id() );
		$manager->destroy_others( $token );
	}
}


Top ↑

Changelog

Changelog
VersionDescription
4.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More