Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:11:27+00:00 2026-06-09T20:11:27+00:00

Even with app.use(express.session({ secret: conf.secret, maxAge : new Date(Date.now() + 360000), expires: new Date(Date.now()

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:11:28+00:00Added an answer on June 9, 2026 at 8:11 pm

    Are the session stores in MongoDB supposed to just stay there even after the session ends?

    This is the expected behaviour if your browser’s cookie expires but the session information has been saved in a persistent backend data store like MongoDB. The two data stores (backend versus browser-based cookie) can have different expiries.

    Assuming you are using connect-mongodb to persist the sessions, the default reapInterval should trigger removal of expired sessions every 60 seconds.

    Since your session expiry is set to “null” these sessions would never expire. The session expiry should be the same as the cookie expires value .. so if it’s not being set you probably need to do a bit of debugging to track down the issue.

    It’s possible that these are old sessions saved before you tried setting the maxAge; I would check if new sessions are setting expires as you’d expect. If so, you may need to manually delete some of the older non-expiring sessions.

    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?

    Yes, Express sessionIDs are 24-character long alphanumeric strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our app runs in jvm 32 bit, even when in windows x64. Now, at
app.js: app.use(express.compiler({ src: __dirname + '/public', enable: ['less']})); app.use(express.static(__dirname + '/public')); In my jade
Almost every Express app I see has an app.use statement for middleware but I
Even the standard blank-window Cocoa app that gets built when you make a new
In iOS, how would I instruct the OS to keep my app running even
Even using the default test code on my app I can't get this working.
My app was built with SDK 2.2.1 version even before 3.0 beta appear. User
my app crashes with this code.. it doesnt even start up.. any ideas guys
My iPhone app generally uses under 5MB of living memory and even in the
My app will no longer run under Snow Leopard, even though it was originally

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.