endSessions
Definition
endSessions
New in version 3.6.
The
endSessions
command expires the specified sessions. The command overrides the timeout period that sessions wait before expiring.Note
Use the
killSessions
command to immediately terminate and remove a session.
Compatibility
This command is available in deployments hosted in the following environments:
MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
Note
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
MongoDB Enterprise: The subscription-based, self-managed version of MongoDB
MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB
Syntax
The command has the following syntax:
{ endSessions: [ { id : <UUID> }, ... ] } )
To run endSessions
, use the db.runCommand( { <command> } )
method.
db.runCommand( { endSessions: [ { id : <UUID> }, ... ] } )
Behavior
Session Identification
MongoDB concatenates each of the specified UUIDs with the hash of the
authenticated user credentials to identify the user's sessions to end.
If the user has no session that match, the endSessions
has no effect.
Access Control
If the deployment enforces authentication/authorization, you must be
authenticated to run the endSessions
command.
A user can only end sessions belonging to the user.