J
J
jenya77712018-03-04 20:37:28
Node.js
jenya7771, 2018-03-04 20:37:28

Session fails in cookie parser?

Hello, in order to authorize users when working through tips, I try to check the session through the cookie parser module , namely the cookieParser.signedCookie(str, secret) method

io.use(function(socket, next) {

  var handshakeData = socket.request;
  handshakeData.cookies = cookie.parse(handshakeData.headers.cookie || '');
  var sidCookie = handshakeData.cookies[config.session.name];

  var sid = cookieParser.signedCookie(sidCookie, config.session.secret);
  console.log(sid)

});

As a result, sid is always equal to sidCookie that was sent to cookieParser.signedCookie for validation, even if I slipped the wrong secret. What can be wrong?

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