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 ); } }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.0.0 | Introduced. |