Skip to content

Send cookies from nodejs in the socket.io-client (Monkeypatch)

License

Notifications You must be signed in to change notification settings

MartianBitcoins/socket.io-client-cookie

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

socket.io-client-cookie

Send cookies from nodejs in the socket.io-client (Monkeypatch)

What?

SocketIO use a javascript implementation of xmlhttprequest (github.com/driverdan/node-XMLHttpRequest) which does not allow settings cookies due to the specification (http://www.w3.org/TR/XMLHttpRequest/) so this is monkey patch to set cookies in the xmlhttprequest lib used by socket io (./node_modules/socket.io-client/node_modules/engine.io-client/node_modules/xmlhttprequest)

Most of the info was taken from here: https://gist.github.com/jfromaniello/4087861

Discussion: socketio/socket.io-client#344 socketio/socket.io-client#587

##Usage

###socket.io-client running on nodejs

var newXhr = require('socket.io-client-cookie'); newXhr.setCookies('mycookie=something'); var socketIO = require('socket.io-client')('Somewhere only we now');

###socket.io

var cookieString = socket.request.headers.cookie; //You can use https://www.npmjs.com/package/socket.io-cookie to parse the cookies or something

About

Send cookies from nodejs in the socket.io-client (Monkeypatch)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%