express-socket.io-session icon indicating copy to clipboard operation
express-socket.io-session copied to clipboard

Socket IO session does not update when express session changes

Open arvi opened this issue 9 years ago • 7 comments

I'm having the same problem as this person (just not about passportJS... I'm trying to set own session).

I'm not sure what I missed. Thanks!

http://stackoverflow.com/questions/35165060/socket-io-session-does-not-update-when-req-session-changes

arvi avatar Aug 12 '16 05:08 arvi

http://stackoverflow.com/questions/35165060/socket-io-session-does-not-update-when-req-session-changes/39060923#39060923

Jimbojones1 avatar Aug 21 '16 04:08 Jimbojones1

Is there a reason this isn't already object oriented? I expect a long running socket would have many updates to the session and possibly from a number of sources. Calling socket.handshake.session.reload() before accessing the session object becomes troublesome.

smujmaiku avatar Jun 19 '17 22:06 smujmaiku

Why?

Jimbojones1 avatar Jun 22 '17 18:06 Jimbojones1

I find objects helpful when passed into promises and other asynchronous functions. Being that these sessions could be changed in a number of ways over periods of time, reusing the same object would be helpful to that end.

smujmaiku avatar Jun 28 '17 18:06 smujmaiku

I had a similar issue where I would login, which would issue a new cookie, but the session handshake still had the old session information. Even a "reload()" would not work because the cookie sessionId was no longer valid. I solved the problem on the client by forcing a reconnect for the socket after login/logout (since I am using regular HTTP for initial login).

When a logout happened, I would call socket.disconnect() then socket.connect() - this is the only thing that worked with the application structure I had.

paustint avatar Apr 18 '18 18:04 paustint

Is there a reason this isn't already object oriented? I expect a long running socket would have many updates to the session and possibly from a number of sources. Calling socket.handshake.session.reload() before accessing the session object becomes troublesome.

TypeError: socket.handshake.session.reload(...) is not a function

Zaniyar avatar Aug 17 '21 13:08 Zaniyar

@Zaniyar Have you ever solved it?

itayganor avatar May 30 '22 21:05 itayganor