I’m using Socket.IO with Node.js.
I have an object socket which looks like this:
SocketNamespace
$events: Object
...
socket: Socket
So then If I look at Socket (i.e. socket.socket)
Socket
$events: Object
...
sessionid: "1549988601982716407"
Again, works fine.
But if I just want to return sessionid, so I use socket.socket.sessionid I get...
undefined
If I do a typeof for socket.socket I get object, but for socket.socket.sessionid, I just get undefined.
Edit: here’s my code:
Browser:
$(function() {
$.getScript('http://localhost:8080/socket.io/socket.io.js', function() {
var socket = io.connect('http://localhost:8080');
console.log(socket.socket.sessionid);
});
});
App:
var io = require('socket.io').listen(8080);
io.sockets.on('connection', function (socket) {
});
Edit 2: More data:
Instead of the one log, I’ve replace with this;
console.log(typeof(socket));
console.log(typeof(socket.socket));
console.log(typeof(socket.socket.sessionid));
Returns:
object
object
undefined
Expected:
object
object
string
Edit 3:* Screenshot
Edit 4
This, oddly, works.
var x;
for (x in socket.socket)
{
if (x == 'sessionid') {
console.log(socket.socket[x]);
}
}

sessionid, but in your edited code you citesession_id. Could this be the problem? Should it besessionid?