E
E
EpicUsaMan2016-07-26 21:51:27
JavaScript
EpicUsaMan, 2016-07-26 21:51:27

Nodejs socketio how to properly push?

io.cookies = [];
io.parseCookies = function() {
console.log(this.cookies); // Возвращает [] в консоль
};
io.sockets.on('connection', function(socket) {
  socket.on('auth', function(msg) {
    var message = JSON.parse(msg);
    io.cookies.push({'id': socket.id, 'user_id': message.id});
    console.log(io.cookies); // Ничего не возвращает в консоль
    io.parseCookies();
  });
});

Actually a question. What am I doing wrong? And how to fix it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question