定义
endSessionsThe
endSessionscommand marks a session as expired to signal to the server to clean up the session and updates the expiration time of the session. The command overrides the timeout period that sessions wait before expiring.注意
使用
killSessions命令立即终止并删除会话。
兼容性
此命令可用于以下环境中托管的部署:
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
注意
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.runCommand( { endSessions: [ { id : <UUID> }, ... ] } )
To run endSessions, use the db.runCommand( { <command> } ) method.
db.runCommand( { endSessions: [ { id : <UUID> }, ... ] } )
行为
会话识别
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.
访问控制
If the deployment enforces authentication/authorization, you must be authenticated to run the endSessions command.
用户只能结束属于该用户的会话。