0

* I don't know English well. So understand me please.

I want to use cookie data to get PHPSESSID. How can I get cookie data?

server.js

io.sockets.on("connection", function(socket){
  var cookies = socket.handshake.headers.cookie;
  socket.emit("debug", cookies);
});

client.js

socket.on("debug", function(data){
  console.log(data);
});

Console Result

connect.sid=s%3AiNWioXwVSG3inLMU6DLHefdB.mS1OBJK6cM%2FXyZSiGBO0%2BMz2jCESsoAmGF9xT9cG52c

I will wait some answer.

TaeSang Cho
  • 245
  • 3
  • 12
  • One option that i used and its one of a couple options, i converted my sesssions from file based setup to a database setup and used `mysql-node`. Alternatively look into `ExpressJS` info here: http://stackoverflow.com/questions/5522020/how-do-sessions-work-in-express-with-nodejs – Sir Dec 15 '13 at 02:24

1 Answers1

1

Try this one.

server.js

io.sockets.on("connection", function(socket){
    var cookies = socket.handshake.headers['cookie'];
    socket.emit("debug", cookies);
});

on the client.js

socket.on("debug", function(data){
    console.log(data.PHPSESSID);
});