0

I'm trying to implement a simple token system after a user logs in and store it as a cookie. I'm pretty sure that this code worked and now it doesn't and I can't figure out what's wrong.

So first step user logs in, nodeJS generates a token and sends it back

    socket.on('response_login',function(responseObj){
    if(responseObj)
    {
        try{
            if(typeof responseObj.token !=="undefined" && responseObj.token !="")
            {
                createCookie("cid",responseObj.token,1);
                console.log(document.cookie);
            }
        }
        catch(e)
        {

        }
    }
});

The console log outputs correctly the new token generated:

fbsr_14386678264=...; cid=xSckyLstgkBveqi0

When I refresh the page, I output the variable socket.handshake.headers.cookie and the result is very strange

io=v8H286btu9yJgHI2AAAC

How come is this possible? Document.cookie is different from socket.handshake.headers.cookie? Is possible to fix it ? Thanks

Diogo Mendonça
  • 903
  • 2
  • 12
  • 29
  • This question may help you http://stackoverflow.com/questions/10771337/adding-a-cookie-value-on-socket-io – Arthur Jun 08 '15 at 20:53
  • i set manually the socket.handshake.headers.cookie as that example but the outcome is the same. Some io=.... in there :( – Diogo Mendonça Jun 08 '15 at 20:59

0 Answers0