0

Currently, I'm using express-session:

https://github.com/expressjs/session

combined with

connect-mongo:

https://github.com/jdesboeufs/connect-mongo

I use the boilerplate examples from the site, and I can successfully generate sessions for logged in users.

But I also have a health monitor which pings the site every few seconds, and this is also generating sessions on the server which is clogging up the database.

How can I generate sessions for logged in users only?

Hoa
  • 19,858
  • 28
  • 78
  • 107

1 Answers1

1

you can define a "control" endpoint in your express app. something like

const app = express()
app.get('/ping', (req,res) => res.send('pong'))
app.use(sessions...)

as you know express mechanism works from top to bottom so the get request have the priority upon the sessions middleware :)

Omer Shacham
  • 618
  • 4
  • 11