node.js - 通过websocket发送cookie

时间:2015-12-21 18:14:25

标签: php node.js cookies

我目前在项目中使用node.js websocket模块。我的浏览器中有PHPSESSID但不包含websocket的请求标题

 Accept-Encoding:gzip, deflate, sdch
 Accept-Language:en-US,en;q=0.8,ka;q=0.6,ru;q=0.4
 Cache-Control:no-cache
 Connection:Upgrade
 Host:someHost
 Origin:someOrigin
 Pragma:no-cache
 Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits
 Sec-WebSocket-Key:0Hq9BZfHAxIMbfu3cJpWyg==
 Sec-WebSocket-Protocol:echo-protocol
 Sec-WebSocket-Version:13
 Upgrade:websocket
 User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36

我已在服务器端代码中检查了它

 wsServer.on('request', function(request) {
      console.log(request.cookies);
 });

并打印一个空数组[]

如何通过websocket发送cookie?我应该使用标题还是其他东西?

0 个答案:

没有答案