V
V
Vladimir2019-06-14 00:57:56
MySQL
Vladimir, 2019-06-14 00:57:56

Authentication (Node.js Express-session), I can't figure out how it works, can you help?

I'm using express-socket.io-session on top to be able to consume data over socket.
Here are the docks: https://www.npmjs.com/package/express-socket.io-session
I'm including them below.

var session = require("express-session")({

    secret'boss',

    resavetrue,

    saveUninitializedtrue,

      cookie: {
        maxAge: 25200000
      }
});

var sharedsession = require("express-socket.io-session");

Here, as far as I understand, I activate them:
app.use(session);

 

// Use shared session middleware for socket.io

// setting autoSave:true

io.use(sharedsession(session, {

    autoSave:true

})); 

The data is entered (sess.connect commented out because I don’t know if it works, and it didn’t help):
sess = socket.handshake.session;
      //sess.connect;
      sess.uid = socket.id;

Explain to me, fool, how it works in simple terms and how to use it for authentication, how to open and close a session, whether session data is deleted after it is closed, etc.

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