Does the new cookie value from socket.io not work?

I am trying to use the socket.io identifier for multiple Window / Page browsers. This is for the SNS-auth process using everyauth , and the project is based on express .

Here is my project:

Full ajax page supporting socket.io connection. Do not restart, do not redirect, etc.

When a user tries to log in through some SNS account, a pop-up window will open that will be controlled by all machines and SNS Auth. There are a lot of redirects inside the popup, but the main window is permanent, because the socket.io connection.

Finally, after successful authorization, everyauth redirects 'authdone.html' in a popup window.

In a browser, this popup is no longer useful, therefore window.close ();

but good login information can be obtained all the time, but in my case a cookie is more important because I do not need session management with an express framework, because I intend to do this session management through socket.IO .

app.get('*',
    function (req, res)
    { 
        console.log("----------get------------");
        console.log(req.url);
        if (req.url == '/public/authdone.html')
        {
            console.log("----------get /public/authdone.html------------");
            console.log(req.cookies);  
            // express(connect) sessionID(sid) cookie available here.
            //{ 'connect.sid': '2DLlayNx90wtTsyeq5w83N9g.Kc1ZFd8I7omf6u4fk4FFyKAt4dP1V6IufSf1ZtRudVI' }
        }
        onreq(req, res);
    });

Currently, I managed to get the express session identifier via a cookie in a pop-up window redirected to the landing page (/public/authdone.html), but this is not enough. I also need to get socket.IO oriented id here in cookie.

Actually, I was embarrassed here and asked a question. Adding cookie value to Socket.IO

Wes cookie ( , ), :

io.configure(function ()
{
    io.set('authorization', function (handshake, callback)
    {
        if (handshake.headers.cookie)
        {
            var cookie = handshake.headers.cookie;
            var newS = ";" 
                + "socketClientID" + "=" 
                + "999999999999999";// eventually randomize for every client
            cookie += newS;
            console.log("=========================================");
            console.log(cookie);  
        } else
        {
            return callback('Cookie not found', false);
        }
        callback(null, true);
    });
});

cookie "SocketClientID = 999999999999999"

, cookie console.log

connect.sid=fc2iTJW3ETD7nIyxI5ZwpayK.S0qGhp1Ryw7Msg2r03yB6g822qVZIZTbZyWUSpQL0aU;
socketClientID=999999999999999

, , everyauth,

----------get /public/authdone.html------------  
{ 'connect.sid': 'fc2iTJW3ETD7nIyxI5ZwpayK.S0qGhp1Ryw7Msg2r03yB6g822qVZIZTbZyWUSpQL0aU' }

sessionID (connect.sid) cookie, cookie ClientID socket.IO.

. .

+3
1

, , cookie .

socketClientID io.sockets.on('connection', function (client)...

socketClientID.

https://github.com/carhartl/jquery-cookie Cookie.

+1

All Articles