diff --git a/README.md b/README.md index cdb7715a5..f15fb8c94 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,14 @@ true The amount of attempts should we make using the current transport to connect to the server? After this we will do one final attempt, and re-try with all enabled transport methods before we give up. +- *'cookie'* + + Any cookies to pass along into the handshake. For example: + +```js + io.connect('http://localhost', {'cookie': 'express-sid=aGRKnI4jThJDdWPxEEZIDIGeH5DlA0Fs'}); +``` + ##### Properties: - *options* diff --git a/lib/socket.js b/lib/socket.js index dff44112d..13d5d94c2 100644 --- a/lib/socket.js +++ b/lib/socket.js @@ -148,6 +148,9 @@ } else { var xhr = io.util.request(); + if (this.options.cookie) { + xhr.setRequestHeader('Cookie', this.options.cookie); + } xhr.open('GET', url, true); xhr.withCredentials = true; xhr.onreadystatechange = function () {