trnc
trnc

Reputation: 21587

Global session variable in express.js route?

when i set a session in express.js route like

app.get('/', function(req, res() {
req.session.foo = 'bar';
});

i can't access it (undefined) in other routes. is this possible? is there a special configuration i have to consider?

thanks!

Upvotes: 4

Views: 1829

Answers (1)

trnc
trnc

Reputation: 21587

i actually solved it by just setting the sessions like this:

global.session.email = JSON.parse(chunk).email;

through this, the session variables are global!

solved!

Upvotes: 1

Related Questions