Wednesday, 17 May 2017

My Express-Socket.io-Session updates but Express Session Doesn't update

I'm using express-socket.io-session module for handling sessions and I kinda don't like using ajax and making REST APIs for it, So for the login authentication system I used Socket.io. The client emits username and password (encrypted) to Socket.io and It checks If the user is verified or not. If It is, it adds a user variable to socket.handshake.session which is equivalent to what database returned.

So When I compare socket.handshake.session.user to req.session.user, there is a drastic difference, Just like this -

Socket Session returns -

{ _id: 'Some-random-id',
  email: 'some-random-email',
  password: 'random-pass',
  __v: 0,
  payments: [],
  accounts: [],
  registeredOn: 2017-05-17T07:08:58.999Z }

Express Session returns -

Session {
  cookie:
   { path: '/',
     _expires: null,
     originalMaxAge: null,
     httpOnly: true } }

I don't know why It's not updating req.session.user, any help is appreciated.



via Daksh Miglani

No comments:

Post a Comment