Why don't mongodb session MongoStore's go away after session ends?

Viewed 3791

Even with

app.use(express.session({
    secret: conf.secret,
    maxAge : new Date(Date.now() + 360000),
    expires: new Date(Date.now() + 360000),//I've tried both separately
    store : new MongoStore(conf.db),


}));

The sessions in mongodb stay forever (as far as I have tested)

Are the session stores in MongoDB supposed to just stay there even after the session ends?
Because even with the maxAge or expires in the session declaration, in MongoDB, all the sessions look like this:

{ "_id" : "FU8k3kEzquG/hoSD308H5XHa", "session" : "{\"cookie
\":{\"originalMaxAge\":null,\"expires\":null,\"httpOnly\":true,
\"path\":\"/\"}}" }

Also, in most of my _id's there is some type of non-number/letter character, i.e. /, +, etc. Are they supposed to be like that?

Every time I re-open my browser, a new session is created, but the old one is still there in MongoDB. I just want to know if there is a fix to this, or if this is intentional.

Thanks, Brandon

2 Answers
Related