Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie is not included in socket.handshake.headers? #1331

Closed
nasser-torabzade opened this issue Oct 20, 2013 · 1 comment
Closed

Cookie is not included in socket.handshake.headers? #1331

nasser-torabzade opened this issue Oct 20, 2013 · 1 comment

Comments

@nasser-torabzade
Copy link

I am using node.js and socket.io. on the client side, I created a socket.io connection and wrote a cookie like this:

var socket = io.connect('http://localhost:3000');
document.cookie="foo=bar";
socket.emit('this', { is: 'test'});

and on the server side, I need to be able to read from that cookie inside a socket.io connection, something like this:

io.sockets.on('connection', function (socket) {
    socket.on('this', function(reqData){ 
        console.log(socket.handshake.headers); // there is no cookies here!
    });
}

you can find my complete code, in this gist.
any help is appreciated. thanks.

@sarahman
Copy link

I think, you should try this:

window.cookie = "foo=bar";
var socket = io.connect('http://localhost:3000');
socket.emit('this', { is: 'test'});

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants