Unexpected Behavior when working with express-session #3738
Unanswered
brandon-hedrick
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on a project with Express and socket.io where I'm attempting to create a websocket-only server. I'd like to create an
express-sessionto store a small amount of information about the user and facilitate re-identifying them in the event of a disconnection. I'm following the guide for usage with express-session but the behavior I'm seeing is unexpected.Expected behavior
set-cookieheader in the response of the socket.io connection storing the cookie in the user's browser.socket.request.sessionObserved behavior
set-cookieheader in the response of the socket.io connection. In fact noset-cookieheader is present whatsoever. This prevents the session from realistically being used.socket.request.sessionhowever a new session is created on every event negating the usefulness of storing anything in it. I believe this behavior is somewhat expected considering the client has no cookie to send back since the above misbehaves.Express/Session/Socketio code
Client code
FWIW I get the same results in Node 12 and 14. My client always successfully connects.
I've spent some time trying to figure out exactly what is wrong but I haven't arrived at anything and I've hit the wall thinking I must have done something wrong or misunderstood the documentation. I'm happy to create a quick repository if that would be more helpful. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions