Permalink
Browse files

fix cookie max-age

the cookie module we depend on never used to
set this value, however now it does :)
  • Loading branch information...
1 parent 1c616e2 commit ab9c275bde7deff97b84aeb3ce16e0504ac64f8d @tj tj committed Nov 13, 2012
Showing with 17 additions and 0 deletions.
  1. +1 −0 lib/response.js
  2. +16 −0 test/res.cookie.js
View
@@ -578,6 +578,7 @@ res.cookie = function(name, val, options){
if (signed) val = 's:' + sign(val, secret);
if ('maxAge' in options) options.expires = new Date(Date.now() + options.maxAge);
if (null == options.path) options.path = '/';
+ options.maxAge /= 1000;
this.set('Set-Cookie', cookie.serialize(name, String(val), options));
return this;
};
View
@@ -92,6 +92,22 @@ describe('res', function(){
done();
})
})
+
+ it('should set max-age', function(done){
+ var app = express();
+
+ app.use(function(req, res){
+ res.cookie('name', 'tobi', { maxAge: 1000 });
+ res.end();
+ });
+
+ request(app)
+ .get('/')
+ .end(function(err, res){
+ res.headers['set-cookie'][0].should.include('Max-Age=1');
+ done();
+ })
+ })
})
describe('signed', function(){

0 comments on commit ab9c275

Please sign in to comment.