1

I was creating an app using socket.io my question is when user opens multiple tabs in same browser it will create new session id [socket.id]. How can i carry same session id in all the tabs?

I went through few posts like in these post danielbaulig its using express session, but how will these post help me to carry same socket.io session id across all the tabs in a browser?

And the above mentioned post is out dated, can you please solve these?

Thank you..

sravis
  • 3,562
  • 6
  • 36
  • 73

3 Answers3

4

You should check out express.io, a very simple micro-framework for express and socket.io. It handles express and socket.io sessions automatically.

npm install express.io

Check out the session support example here:

https://github.com/techpines/express.io/tree/master/examples#sessions

Brad C
  • 720
  • 8
  • 14
1

Answering my own question;

2 posts below helped me to resolve the issue. if you are facing same issue then links below might help you.

https://gist.github.com/2640463

Manage multiple tabs (but same user) in socket.io

Community
  • 1
  • 1
sravis
  • 3,562
  • 6
  • 36
  • 73
0

You can try this module express-socket.io-session.

It allows you to shared cookie-based session data between express and socket.io (and viceversa).

So, even if every tab socket has different id they'll be sharing the session data based on the coookie every tab shares for being the same HTTP agent.

It works for express >4.0 and socket.io >1.0

Osk
  • 198
  • 6