问题
I'm creating simple web app in node.js which should be able to save session data into file store.
For this purpose I'm using express-session with session-file-store module:
var session = require('express-session');
var FileStore = require('session-file-store')(session);
app.use(session({
store: new FileStore({
path:'./sessions/',
}),
secret: 'keyboard cat'
}));
But when I visit some page of my website, I will successfully receive generated HTML file, but all other request for assets will be aborted:
When I comment store attribute, it works fine.. but it won't save session data into files.
Does anybody know, what's wrong here? Or do you know any other module for storing session data into files?
Thanks for any advice..
回答1:
It seems like you have problems with permissions on your file system if it works with default in memory storage.
Try to create session store this way:
new FileStore({
path: require('path').join(require('os').tmpdir(), 'sessions')
})
It has to resolve this issue.
来源:https://stackoverflow.com/questions/28919667/node-js-session-file-store-will-abort-all-following-requests