I know that I can set cookies during handshake:
const wss = new WebSocketServer({ server, path: \'/ws\' });
wss.on(\'headers\', headers => {
headers.push(\'
You can't set a cookie upon receipt of a webSocket message. Once the webSocket connection has been established, it's an open TCP socket and the protocol is no longer http, thus there is no built-in way to exchange cookies.
You can send your own webSocket message back to the client that tells it to set a cookie and then be listening for that message in the client and when it gets that message, it can set the cookie in the browser.