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
-
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-session
to 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-cookie
header in the response of the socket.io connection storing the cookie in the user's browser.socket.request.session
Observed behavior
set-cookie
header in the response of the socket.io connection. In fact noset-cookie
header is present whatsoever. This prevents the session from realistically being used.socket.request.session
however 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