问题描述
如果用户已经登录并尝试在新实例中重新登录,我希望它注销另一个用户实例。我不希望在我的应用程序中登录两次。
If a user is already logged in and tries to login again in a new instance I'd like it to log out the other user instance. I don't want the same user to be logged in twice on my application.
目前,会话存储在Redis商店中,我使用express / connect处理会话存储。可用于销毁会话的功能之一如下:
Currently the session is stored in a Redis store, i'm using express / connect to handle the session storage. One of the functions available which could be used to destroy the session is as follows:
.destroy(sid, callback)
但是,在调用.destroy()之前,我需要找到该会话ID。在Redis中,用户名被存储为会话的一部分。
However I need to find that session id before I call .destroy(). In Redis the username is stored as a part of the session.
问题:是否可以根据用户名查询Redis获取会话ID?
推荐答案
req.sessionID将为您提供会话的SID。
req.sessionID will provide you the session's SID.
这篇关于使用快递/连接和会话存储时,如何查找会话ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!