Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when are sessions deleted from the database? #88

Open
evanholt1 opened this issue Oct 9, 2020 · 1 comment
Open

when are sessions deleted from the database? #88

evanholt1 opened this issue Oct 9, 2020 · 1 comment

Comments

@evanholt1
Copy link

i am using express-session & this package, and this is my test setup:
`
let sessionStore = new MongoDBStore({
uri: process.env.DB_HOST,
collection: 'sessions',
expires: 1,
});

app.use(session({
secret: process.env.SECRET,
store: sessionStore,
resave: false,
saveUninitialized: false,
unset: "destroy",
cookie: {
maxAge: 1
},
name: "US" // User Session
}));
`
yet when i run a GraphQL mutation which adds an "_id" field to 'req.session', while the cookie doesnt appear on client-side(it lasts a millisecond), a session is created on the database, and lasts a dynamic amount of time (lasting from 1 second to a minute) while i would expect it to expire in 1 millisecond, then destroyed from the database.
what is the explanation of this? what am i missing?

@nickgarver
Copy link

nickgarver commented Feb 1, 2021

mongo expireAfterSeconds / TTL only runs every 60 seconds. even if it expired it would still take whatever time is remaining in the 60 second window to delete the entry (i.e. 30ish seconds if it expires immediately)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants