I want to get session id of client in my socket.io client.
here is my socket.io client :
var socket = new io.Socket(config.host, {port: config.port, rememberTransport: false});
// when connected, clear out display
socket.on('connect',function() {
console.log('dummy user connected');
});
socket.on('disconnect',function() {
console.log('disconnected');
});
socket.connect();
return socket;
I want to get session id of this client , how can i get that ?
On socket.io >=1.0, after the connect event has triggered:
Try from your code socket.socket.sessionid ie.
For some reason
did not work for me. However
did work for me. Hopefully this is helpful for people who also had issues with getting the id. I use Socket IO >= 1.0, by the way.
I just had the same problem/question and solved it like this (only client code):
Have a look at my primer on exactly this topic.
UPDATE:
Try this way.