I am using session-file-store to maintain the sessions in my Node-Express app.
session-file-store generates a new file for every session. This will create lots of files on the server over time.
Is there any option / way to automatically delete the file after the session expiry?
Here is the part of the code I am using for this -
.
.
const session = require('express-session');
const FileStore = require('session-file-store')(session);
.
.
app.use(session({
genid: (req) => {
return uuid() // use UUIDs for session IDs
},
store: new FileStore(),
secret: MY_SECRET,
resave: false,
saveUninitialized: true,
cookie: { maxAge : SESSION_COOKIE_TIMEOUT }
}));
.
.
Here is the sample file that gets generated by session-file-store -
{"cookie":{"originalMaxAge":59999,"expires":"2019-03-27T03:28:21.597Z","httpOnly":true,"path":"/"},"__lastAccess":1553657241598}