killSessions

Definition

  • killSessions

New in version 3.6.

The killSessions command kills the specified sessions.If access control is enabled, the command only kills the sessionsowned by the user.

Note

Killing a session kills any in-progress operations in thesession, and closes any open cursors associated with theseoperations. The killed session may still be listed as acurrent session, and future operations may use the killedsession.

killSessions has the following syntax:

  1. { killSessions: [ { id : <UUID> }, ... ] } )

The command takes an array of documents that specify the UUIDportion of the session id. If you specify an empty array, thecommand kills all sessions, or if access control is enabled, allsessions owned by the user.

To run killSessions, use the db.runCommand( { <command> } ) method.

To view existing sessions, see $listSessions operationor $listLocalSessions.

Behavior

Session Identification

MongoDB concatenates each of the specified UUIDs with the hash of theauthenticated user credentials to identify the user’s sessions to kill.If the user has no session that match, the killSessionshas no effect.

Example

The following operation kills the specified session for the user:

  1. db.runCommand( { killSessions: [ { id: UUID("f9b3d8d9-9496-4fff-868f-04a6196fc58a") } ] } )

See also

Kill Write Operations