Answer the question
In order to leave comments, you need to log in
Why does express-session store guest sessions, and how can we ignore the recording of such sessions?
The problem is the following.
Users often complained about the fact that the session flew quickly, increased the session storage period to 3 months and the database swelled up, don't worry, for example, in just one day, half a million documents in the db.sessions collection Normal
config
app.use(session({
secret: 'secret',
cookie: { path: '/', httpOnly: !0, maxAge: 7776000000, secure: 0 },
name: 'sid',
store: sessionStore,
saveUninitialized: 0,
resave: 0
}))
const mongoose = require('mongoose')
, expressSession = require('express-session')
, MongoStore = require('connect-mongo')(expressSession)
, sessionStore = new MongoStore({
mongooseConnection: mongoose.connection,
autoRemove: 'interval',
autoRemoveInterval: 1
})
module.exports = sessionStore
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question