Using session variables in jade template in node js

is there any alternate for using session variables in jade template file other than using dynamic helper function and passing it through res.render? if i use dynamichelpers method its showing error since it is deprecated. please help

app.use(function(req, res, next){
            res.locals.user = "xxxx";
            next(); 
        }); 

i used this code in app.js inside app.configure function. but still i couldn't use the variable user in my view. do i need to install any additional packages or any other code?

This code should work. For example, I'm using nearly identical code in one of my production systems:

app.use(function (req, res, next) {
    app.locals.token = req.session._csrf;
    app.locals.user = req.user;
    ...
    next();
});

You'll need to make sure this code is after you set req.locals.user - for example, if you are using Passport, after you do the initialize and session code, but before you actually handle and render the request.