Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
41
rated 0 times [  45] [ 4]  / answers: 1 / hits: 15942  / 11 Years ago, thu, november 7, 2013, 12:00:00

I know how to retrieve the client sessionID when the user connects.



But I'd like to retrieve it at any time, for example when the client clicks on something, I would like to be able to know who clicked, what their sessionID was.



socket.sessionID doesn't work, nor does socket.handshake.sessionID



For example :



I have this express route :



.get('/result/:survey', function(req, res) {
res.redirect('/result/'+req.params.survey+'/1');
})


Just before the redirection, I'd like to make the user join a socket room, and also get their sessionID. How could I possibly do that ? According to the doc, it would be socket.join('room') but I doubt socketonly represents the connection I have with the client, and not with the other clients. Maybe I'm just having trouble understanding sockets !


More From » node.js

 Answers
1

As of version 1.0, you get the client's sessionid this way:



var socket = io();
socket.on('connect', function(){
var sessionid = socket.io.engine.id;
...
});

[#74433] Wednesday, November 6, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
samaraanandah

Total Points: 94
Total Questions: 86
Total Answers: 99

Location: Montenegro
Member since Thu, Jun 16, 2022
2 Years ago
;