Skip to content

Commit

Permalink
change the way we interface cookie session stuff so that expiry is pr…
Browse files Browse the repository at this point in the history
…operly updated every time a cookie is issued. works around an upstream bug.
  • Loading branch information
lloyd committed Sep 26, 2011
1 parent 9f28469 commit c2bb833
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions server/main.js
Expand Up @@ -40,22 +40,23 @@ app.use(express.cookieParser());
// parse post bodies
app.use(express.bodyParser());

// session support using encrypted cookies
var cookieSession = sessions({
secret: COOKIE_SECRET,
key: 'myfavoritebeer_session',
cookie: {
path: '/api',
httpOnly: true,
// when you're logged in, you're logged in for an hour
maxAge: (1 * 60 * 60 * 1000),
secure: false
}
});

// session support using signed cookies
app.use(function (req, res, next) {
if (/^\/api/.test(req.url)) return cookieSession(req, res, next);
return next();
if (/^\/api/.test(req.url)) {
return sessions({
secret: COOKIE_SECRET,
key: 'myfavoritebeer_session',
cookie: {
path: '/api',
httpOnly: true,
// when you're logged in, you're logged in for an hour
maxAge: (1 * 60 * 60 * 1000),
secure: false
}
})(req, res, next);
} else {
return next();
}
});

// The next three functions contain some fancy logic to make it so
Expand Down

0 comments on commit c2bb833

Please sign in to comment.