1

I would like to send additional headers from javascript socket.io client when socket connection is being established with XHR to the server.

Actually, I'm trying to send PHPSESSID from the current page to the socket.io/nodejs server via javascript to check whether user is loggedin in the php application.

I've read this thread, and I'm using this technique to send additional data to the server via query parameters. But I would like to know whether it is possible to send it as headers instead of sending it in query string.

Thank You

kabirbaidhya
  • 2,581
  • 2
  • 29
  • 51
  • Other than the WebSocket-Protocol header etc, websockets don't have headers, that's sorta the point, low overhead and no additional data. – adeneo Jan 12 '15 at 07:54
  • @adeneo You mean we can't send additional headers in that XHR request that the socket.io client sends to the server? Then is it possible to modify existing headers before the request is sent? eg: can we change the "Cookie" header's value. – kabirbaidhya Jan 12 '15 at 07:58
  • No, you can't change the headers, and you can't pass additional headers in Websockets. The real question is what the heck would you send PHP's session ID to Node.js for, or even with a websocket connection at all, it makes no sense. – adeneo Jan 12 '15 at 08:00
  • I just want to make sure the user is loggedin in the php application. – kabirbaidhya Jan 12 '15 at 08:03
  • What's wrong with sending it with query data? – Farid Nouri Neshat Jan 12 '15 at 09:16

0 Answers0