-
-
Notifications
You must be signed in to change notification settings - Fork 994
Description
Similar to #148, I'm can't seem to set a manual sessionID. Setting it in signedCookies like seems to be the solution doesn't seem to work:
app
.use(function(req, res, next) {
if(req.query.sessionID) {
req.signedCookies["connect.sid"] = req.query.sessionID;
}
next();
})
.use(session({
httpOnly: false,
secret: 'secret',
resave: false,
saveUninitialized: true
})
.get('/session', function(req, res) {
console.log('sessionID:', req.sessionID);
req.session.tmp = req.session.tmp + 1 || 0;
req.session.save();
res.send('session: ' + req.session.tmp);
})When I hit http://localhost:3000/session?sessionID=42 a couple of times, the counter goes up. When I hit that exact same url in a different browser I expect it to pick up the count from the session, but it does not.
An observation: The log for req.sessionID is not what I gave to the query string, so I guess it's initialising its own sessionID instead.
I've also tried a custom genid like so:
.use(session({
httpOnly: false,
secret: 'secret42',
resave: false,
saveUninitialized: true,
genid: function(req) {
return req.query.sessionID || uuid.v1();
}
})This seemed like a cleaner solution anyway, but it also doesn't work for me. It sets the sessionID correctly for the first hit, but it won't update it for requests with a different sessionID.
Any help on this would be great!