最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to post request header cookie in WebSocket javascript - Stack Overflow

programmeradmin1浏览0评论

So basically I want to get authentication with my websocket and the authentication required cookies, so how can I post request my cookies into websocket in js.

here is my code

var uri = 'ws://' + window.location.hostname + window.location.pathname.replace('default.htm', '') + 'chat.ashx?username=' + username;
websocket = new WebSocket(uri);

So basically I want to get authentication with my websocket and the authentication required cookies, so how can I post request my cookies into websocket in js.

here is my code

var uri = 'ws://' + window.location.hostname + window.location.pathname.replace('default.htm', '') + 'chat.ashx?username=' + username;
websocket = new WebSocket(uri);
Share Improve this question asked Apr 21, 2017 at 8:07 awancilikawancilik 1551 gold badge1 silver badge9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 12

As mentioned here you can't actually set headers to a WebSocket() call but you can do what you are already doing, adding arguments to the URI.

Now for cookies, they should be passed along with your call check here for more info.

发布评论

评论列表(0)

  1. 暂无评论