public function destroy( $args, $assoc_args ) {
		$user    = $this->fetcher->get_check( $args[0] );
		$token   = Utils\get_flag_value( $args, 1, null );
		$all     = Utils\get_flag_value( $assoc_args, 'all', false );
		$manager = WP_Session_Tokens::get_instance( $user->ID );

		if ( $token && $all ) {
			WP_CLI::error( 'The --all flag cannot be specified along with a session token.' );
		}

		if ( $all ) {
			$manager->destroy_all();
			WP_CLI::success( 'Destroyed all sessions.' );
			return;
		}

		$sessions = $this->get_all_sessions( $manager );

		if ( ! $token ) {
			if ( empty( $sessions ) ) {
				WP_CLI::success( 'No sessions to destroy.' );
			}
			$last  = end( $sessions );
			$token = $last['token'];
		}

		if ( ! isset( $sessions[ $token ] ) ) {
			WP_CLI::error( 'Session not found.' );
		}

		$this->destroy_session( $manager, $token );
		$remaining = count( $manager->get_all() );

		WP_CLI::success( "Destroyed session. {$remaining} remaining." );
	}
public function destroy( $args, $assoc_args ) {
		$user    = $this->fetcher->get_check( $args[0] );
		$token   = Utils\get_flag_value( $args, 1, null );
		$all     = Utils\get_flag_value( $assoc_args, 'all', false );
		$manager = WP_Session_Tokens::get_instance( $user->ID );

		if ( $token && $all ) {
			WP_CLI::error( 'The --all flag cannot be specified along with a session token.' );
		}

		if ( $all ) {
			$manager->destroy_all();
			WP_CLI::success( 'Destroyed all sessions.' );
			return;
		}

		$sessions = $this->get_all_sessions( $manager );

		if ( ! $token ) {
			if ( empty( $sessions ) ) {
				WP_CLI::success( 'No sessions to destroy.' );
			}
			$last  = end( $sessions );
			$token = $last['token'];
		}

		if ( ! isset( $sessions[ $token ] ) ) {
			WP_CLI::error( 'Session not found.' );
		}

		$this->destroy_session( $manager, $token );
		$remaining = count( $manager->get_all() );

		WP_CLI::success( "Destroyed session. {$remaining} remaining." );
	}
public function destroy ( $ args , $ assoc_args ) { $ user = $ this -> fetcher -> get_check ( $ args [ 0 ] ) ; $ token = Utils \ get_flag_value ( $ args , 1 , null ) ; $ all = Utils \ get_flag_value ( $ assoc_args , 'all' , false ) ; $ manager = WP_Session_Tokens :: get_instance ( $ user -> ID ) ; if ( $ token && $ all ) { WP_CLI :: error ( 'The --all flag cannot be specified along with a session token.' ) ; } if ( $ all ) { $ manager -> destroy_all ( ) ; WP_CLI :: success ( 'Destroyed all sessions.' ) ; return ; } $ sessions = $ this -> get_all_sessions ( $ manager ) ; if ( ! $ token ) { if ( empty ( $ sessions ) ) { WP_CLI :: success ( 'No sessions to destroy.' ) ; } $ last = end ( $ sessions ) ; $ token = $ last [ 'token' ] ; } if ( ! isset ( $ sessions [ $ token ] ) ) { WP_CLI :: error ( 'Session not found.' ) ; } $ this -> destroy_session ( $ manager , $ token ) ; $ remaining = count ( $ manager -> get_all ( ) ) ; WP_CLI :: success ( "Destroyed session. {$remaining} remaining." ) ; }
Destroy a session for the given user.

## OPTIONS

<user>
: User ID, user email, or user login.

[<token>]
: The token of the session to destroy. Defaults to the most recently created session.

[--all]
: Destroy all of the user's sessions.

## EXAMPLES

# Destroy the most recent session of the given user.
$ wp user session destroy admin
Success: Destroyed session. 3 sessions remaining.

# Destroy a specific session of the given user.
$ wp user session destroy admin e073ad8540a9c2...
Success: Destroyed session. 2 sessions remaining.

# Destroy all the sessions of the given user.
$ wp user session destroy admin --all
Success: Destroyed all sessions.

# Destroy all sessions for all users.
$ wp user list --field=ID | xargs -n 1 wp user session destroy --all
Success: Destroyed all sessions.
Success: Destroyed all sessions.
Destroy a session for the given user .