Skip to content

Why don't I see any cookie sent for 2.x ? #3969

Answered by darrachequesne
qiulang asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, there's no cookie when using only WebSocket, in all versions.

It wouldn't make sense to send a cookie, since there is a single HTTP request (the WebSocket connection) for the whole session, and the cookie is not used upon reconnection.

You can add additional headers in the response though:

io.engine.on("initial_headers", (headers, req) => {
  headers["test"] = "123";
  headers["set-cookie"] = "mycookie=456";
});

Reference: https://socket.io/docs/v4/server-instance/#Server-engine

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@qiulang
Comment options

Answer selected by darrachequesne
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants