express 中定义session 时,总说报未定义。req.session.user = '123’;
//定义共享环境
app.configure(function(){
app.use(express.methodOverride());
app.use(express.bodyParser());
app.use(app.router);
app.use(express.cookieParser());
app.use(express.session({secret:'poynt'}));
});
//定义开发环境
app.configure('development',function(){
app.use(express.static(__dirname+'/public'));
app.use(express.errorHandler({dumpExceptions:true, showStack:true}));
});
//定义生产环境
app.configure('production', function(){
app.use(express.static(__dirname+'/public', {maxAge:36000*24*365}));
app.use(express.errorHandler());
});
routers(app);
app.listen(8000);
5 回复
//定义共享环境app.configure(function(){
app.use(express.methodOverride());
app.use(express.bodyParser());
app.use(app.router);
app.use(express.cookieParser());
app.use(express.session({secret:'poynt'}));});