I wanted to send a websocket confirmation request from the html page and write the codes as shown below:
document.cookie = "guestId=xxxx; remember=xxxxxx;"; var ws = new WebSocket("ws://localhost:5000/ws");
But what is shown in Chrome Dev Tools shows that the cookie is not sent:
General: Request URL:ws://localhost:5000/ws Request Method:GET Status Code:307 Temporary Redirect Response Headers Content-Length:59 Content-Type:text/html; charset=utf-8 Date:Fri, 18 Mar 2016 09:39:11 GMT Location:/preorder/landing/index Request Headers Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4 Cache-Control:no-cache Connection:Upgrade Host:localhost:5000 Origin:http://localhost:63342 Pragma:no-cache Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits Sec-WebSocket-Key:t3N0vVaLCsOmOXLSh+Arsw== Sec-WebSocket-Version:13 Upgrade:websocket User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36
How can i fix this? Why are there no cookies in the request headers? If I send another ajax request not updated, I can see the cookies in Dev Tools. Why are there such differences?
source share