这是我的 Express 应用程序配置的样子:
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.cookieSession({secret: conf.sessionSecret}));
app.use(express.session({secret: conf.sessionSecret}));
app.use(app.router);
每当我这样做时:
app.get('/logout', function (req, res)
{
res.clearCookie('userId');
req.session.destroy();
res.redirect('/login');
});
我得到:
TypeError: Object #<Object> has no method 'destroy'.
取出 app.use(express.cookieSession()); 修复它。为什么是这样?