If I enable the session feature of express via app.use(express.session({secret: "12345"}));
the session cookie is set when the user first hits a page.
How can I disable this behavior and decide manually when to create a cookie, for example after a successful login? I am aware that I could just construct a cookie-header manually, but I would like to stay with express.session.
Define the session support as middleware, but don't use use
:
var sessions = express.session({
// etc
});
...
app.get('/', function (req, resp) {
// No session
});
app.post('/user', sessions, function (req, resp) {
// Has sessions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With