             Socket = global.MozWebSocket or global.WebSocket
 
         url = @prepareUrl() + query
-        @websocket = new Socket url, headers: 'Cookie': jar.authCookie
+        @websocket = new Socket url, headers: 'Cookie': jar.cookies.join('; ')
 
         @websocket.onopen = ->
             self.onOpen()

    originalXHR = require('xmlhttprequest').XMLHttpRequest
    xhrPackage = 'socket.io-client/node_modules/xmlhttprequest'
    request = require 'request-json/node_modules/request'
    @jar = jar = {}

    require(xhrPackage).XMLHttpRequest = ->
        originalXHR.apply @, arguments


        @open = ->
            stdOpen.apply @, arguments
            @setRequestHeader 'cookie', jar.cookies.join('; ')
        @

helpers.patchSocketIO = ->
