对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

endSessions(数据库命令)

endSessions

endSessions命令将会话标记为已过期,以向服务器发出信号以清理会话并更新会话的过期时间。该命令会覆盖会话在过期之前等待的超时时间。

注意

使用killSessions命令立即终止并删除会话。

此命令可用于以下环境中托管的部署:

  • MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务

注意

所有 MongoDB Atlas 集群都支持此命令。有关 Atlas 对所有命令的支持的信息,请参阅不支持的命令

该命令具有以下语法:

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.

如果部署强制身份验证/授权,则必须通过身份验证才能运行endSessions 命令。

用户只能结束属于该用户的会话。

给本页内容打分