I'm trying to set a cookie in the express framework, but it isn't going through, and for the life of me I can't figure out why. The relevant code looks like this:
module.exports = function(app) {
return function(req, res, next) {
if (req.cookies.user_token) {
req.session.cookie.httpOnly = false
res.cookie('user_token', req.cookies.user_token, { domain: 'www.example.com', httpOnly: false, path: '/', maxAge: 900000 });
}
return res.redirect('https://www.example.com/index.jsp?other_stuff=value');
}
}
I can see the request going out, and that cookie is NOT getting set. I've stepped through with a debugger, and I know for certain that code is getting hit.
I found this question:
How to set cookie in node js using express framework?
Based on that, I tried calling var express = require('express'); app.use(express.cookieParser());
earlier in the code, but it didn't seem to make any difference.
Anybody have any ideas where I'm going wrong here?