You'll need your SessionManager object -
$session_manager = $vim->get_view(mo_ref => $vim->get_service_content()->sessionManager,properties => ['currentSession'] );$current_session = $session_manager->{currentSession};
And finally call SessionIsActive() with the userName and key (sessionId) from the currentSession -
$is_active = $session_manager->SessionIsActive( sessionID => $current_session->{key},
userName => $current_session->{userName} );