connect - node.js request session property -
i try learn, how build app node.js, express , backbone. user authentication use cookie , session middleware,
app.use(express.cookieparser()); app.use(express.session({secret: "socialnet secret key", store: new memorystore()}));
now, if request comes in, can use session property
req.session
i encounter code snippet book
app.post('/login', function(req, res) { console.log('login request'); var email = req.param('email', null); var password = req.param('password', null); if ( null == email || email.length < 1 || null == password || password.length < 1 ) { res.send(400); return; } account.login(email, password, function(success) { if ( !success ) { res.send(401); return; } console.log('login successful'); req.session.loggedin = true; res.send(200); }); });
look @ req.session.loggedin, loggedin property comes from? can add own request session property req.session property?
Comments
Post a Comment