如何使每个用户的会话都是唯一的?- 节点.js [英] How to make sessions unique for each user? - Node.js
问题描述
我目前正在处理一个节点项目,我的问题是,如果我在一台计算机上登录该网站并在另一台计算机上执行相同操作,我仍然会登录到该帐户.我认为这与使会话唯一的问题有关.这是我用于会话的中间件:
I am working on a node project at the moment and my problem is that if I log into the website on one computer and I do the same for the other computer I will still be logged in into the account. I think this has to do with a problem with making the sessions unique.Here is the middleware that I am using for the session:
app.use(session({
secret:"HelloWorld"
}));
如果有人想在这里查看节点文件,请访问:http://pastebin.com/euatwkNS
If anyone wants to see the node file here it is: http://pastebin.com/euatwkNS
任何帮助将不胜感激!
推荐答案
您是否尝试过使用 genid
方法.
Have you tried using genid
method.
app.use(session({
genid: function(req) { return uuid(); },
secret:"HelloWorld"
}));
您已经导入了 uuid
.它应该可以工作.
You already have uuid
imported. It should work.
注意生成唯一 ID 时要小心,以免您的会话发生冲突.
NOTE be careful to generate unique IDs so your sessions do not conflict.
更多信息:express-session
这篇关于如何使每个用户的会话都是唯一的?- 节点.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!