How does express-session set the expiration time of sessionID

  node.js, question

green hand

In the case of “auth”, the official express login authentication, it is only necessary to log in once during the session.
However, after the browser is closed, the sessionID will disappear. how can I set an expiration time for this sessionID?
So that the next time you open your browser, you won’t have to log in again.

The main reason is that this sessionID is generated automatically. (default name is connect.sid)
(It seems that if the sessionID does not exist, one will be automatically generated before accessing the corresponding res.session.*)
After sessionID is generated, it can be obtained with req.cookies.sessionID
But the setting will not work:
res.cookie(‘sessionID’, req.cookies.sessionID, { maxAge: 60000 }); //invalid

The session of the server is cached in memory by default. Restarting the service will cause the session to disappear.
The general production environment is cached in the database.
SessionID is a token that the server sets up at the front endcookie, and then set the cookie’s max-age to control the aging of sessionID. When the cookie expires, the front end will have no token to access the server again, that is, the login has expired.

 secret: 'xxxx',
 Name: 'xxxxID', // the name value here is the name of the cookie, and the name of the default cookie is: connect.sid
 cookie: {
 //domain:' xxxx',//domain name
 Path:' path'
 HttpOnly: true, // the front end cannot operate through JS after being opened.
 MaxAge: 1800000 // This one controls the expiration time of sessionID!  !  !
 },//set maxAge to 80000ms, i.e. session and corresponding cookie expire after 80s
 resave: false,
 saveUninitialized: true,

After accessing the interface, you need to set the user information field for the session. User = {field information}

Finally, I suggest you go to npm search session and read other people’s documents. The above description is very detailed