is there any possible method for me to delete specific session from mongoDB?
My scenario is to allow 'myself' to delete specific session from DB (other user session). Reading from connect-mongo docs, I can use destory but looks like this method is to destroy my own session (req.session.destroy()). Is there a way for me to achived this?
something like
const expressSession = require('express-session')
const MongoStore = require('connect-mongo');
MongoStore.destroy('some random user session id')
My config: Express + express-session with connect-mongo + mongoDB
I am trying to do something similar. During testing, I want to be able to clear all session. I sort of have this working.
My approach is just to reach into the sessions collections and delete all documents.
This code is called via the route
/api/setup/clearsessions. *PREVIOUSLY this was the case: The code works, but then connect-mongo throws and error saying "Error: unable to find the session to touch". However, the error thrown by connect-mongo does not cause problemsI fixed the errors by adding
await req.session.destroy();.