我正在尝试将我的会话变量传递到我的手柄模板中,但遇到了困难。现在我正在使用以下内容在我的app.configure函数中:
app.use(function(req, res, next){
res.locals.session = req.session;
console.log(res.locals.session);
next();
});
它成功地记录到控制台,但是当我尝试在我的Handlebars模板中使用"session"变量时,什么都没有显示出来。这是我的模板的一部分:
<body>
<nav>
{{> topBarPartial}}
{{> secondaryBarPartial}}
</nav>
<div>
<p>before</p>
{{session}}
<p>after</p>
{{> mainPartial}}
</div>
{{> footerPartial}}
</body>
这是控制台记录的内容:
{ cookie:
{ path: '/',
_expires: null,
originalMaxAge: null,
httpOnly: true },
userId: 45253262,
name: 'Austin' }
有什么想法吗?