Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

here is my code

var uri = 'ws://' + window.location.hostname + window.location.pathname.replace('default.htm', '') + 'chat.ashx?username=' + username;
websocket = new WebSocket(uri);
like image 788
awancilik Avatar asked Apr 21 '17 08:04

awancilik


1 Answers

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.

like image 111
Rami GB Avatar answered Oct 17 '22 06:10

Rami GB