Is there any way to prevent the multiple browser windows from sharing the same session using Connect and redis DB? I have gone through the link Working with Sessions in Express.js. But this is implemented with Express. I want the similar goal to be implemented with Connect.
Any help on this will be really helpful.
How do I prevent multiple browser windows from sharing the same session in node.js?
2.3k views Asked by user87267867 At
2
There are 2 answers
0
On
It would help if you were to specify more about what you are trying to do and maybe even why. By multiple browser windows I assume you mean in the same browser. As @Ivan Plenty said, browser windows/tabs all share cookie information and that's pretty much standard. The only way to get away from that is to use the various incognito modes of each browser.
That said, if you want a way to specifically create sessions per window or to distinguish between windows then you could employ a scheme of passing a csrf token around. Normally this is used for security reasons but you could tailor it to your needs. Have a look here for Connect's csrf.
Most modern browsers have a shared pool for cookies, which is how express typically manages sessions. Different browser windows are just using the same cookies, and the issue lies with how browsers work.
I would recommend one of two options: