![why](/static/img/x1mno0Ukhc-600.jpeg)
Accessing sessions in your Jade template is not straight forward, as in “it just works”. In order to do so, you have to use the Middleware. In short put the following in your app.js/server.js:
[code]app.use(function(req,res,next){
res.locals.session = req.session;
next();
});
[/code]
Note: Make sure you insert the above before app.use(app.router);
Once done you are now able to access your sessions with #{session.myvar} in your Jade templates.
Enjoy 🙂