session-mongoose 用了这个存储session 为什么 req.session.user = user;
写不进去值呢
6 回复
var store = new SessionStore({ url: "mongodb://192.168.62.213/session", interval: 120000 });
app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.cookieParser());
app.use(express.session({ secret : 'shiqiliang’, store: store, cookie: { maxAge: 900000 } }));
这么配置好以后 如果要存储一个值到session的话怎么操作,req.session.user = user;是这样就自动存到mongo的数据库里面了吗?
@shiqiliang 我也遇到过这个问题,我是把 app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.cookieParser()); app.use(express.session({ secret : 'shiqiliang’, store: store, cookie: { maxAge: 900000 } }));这段代码插在app.use(app.router);前面解决了问题