I want to log a user in and store there session so i can identify them. and then have some code on the back end that gets there data from and allows me to pass the username into another db method.
i have the following, but want to use session without having to add it to every page i need it on, or is that not possible?
var express = require('express');
var app = express();
app.use(express.cookieParser());
app.use(express.session({secret: '1234567890QWERTY'}));
app.get('/awesome', function(req, res) {
if(req.session.lastPage) {
res.write('Last page was: ' + req.session.lastPage + '. ');
}
req.session.lastPage = '/awesome';
res.send('Your Awesome.');
});
app.get('/radical', function(req, res) {
if(req.session.lastPage) {
res.write('Last page was: ' + req.session.lastPage + '. ');
}
req.session.lastPage = '/radical';
res.send('What a radical visit!');
});