简体   繁体   English

如何在WebSocket javascript中发布请求标头cookie

[英]How to post request header cookie in WebSocket javascript

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. 所以基本上我想用我的websocket和身份验证所需的cookie进行身份验证,那么如何在js中将请求我的cookie发布到websocket中。

here is my code 这是我的代码

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

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. 如此处所述您实际上无法将标头设置为WebSocket()调用,但您可以执行您正在执行的操作,并为URI添加参数。

Now for cookies, they should be passed along with your call check here for more info. 现在,饼干,就应该连同您的通话检查通过这里获得更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM