Skip to content
Myr

Added options support to res.clearCookie()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent e0bc571 · Browse files · 3 files+9 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+9 added−5 removed

  • tests:+2 added−2 removed
  • other:+7 added−3 removed

3 files+9 added−5 removed

modified:docs/guide.md+1 added-1 removed
892 unmodified lines
893 app.get('/', function(req, res){894 // use req.cookies.rememberme895 });896897### res.clearCookie(name)897### res.clearCookie(name[, options])898899Clear cookie _name_ by setting "expires" far in the past.900901 res.clearCookie('rememberme');
439 unmodified lines
modified:lib/response.js+6 added-2 removed
244 unmodified lines
245/**246 * Clear cookie `name`.247 *248 * @param {String} name249 * @param {Object} options250 * @api public251 */252252res.clearCookie = function(name){253 this.cookie(name, '', { expires: new Date(1) });253res.clearCookie = function(name, options){254 var opts = { expires: new Date(1) };255 this.cookie(name, '', options256 ? utils.merge(options, opts)257 : opts);258};259260/**261 * Set cookie `name` to `val`, with the given `options`.
159 unmodified lines
modified:test/response.test.js+2 added-2 removed
568 unmodified lines
569 'test #clearCookie()': function(){570 var app = express.createServer();571 572 app.get('/', function(req, res){573 res.clearCookie('rememberme');573 res.clearCookie('rememberme', { path: '/foo' });574 res.redirect('/');575 });576 577 assert.response(app,578 { url: '/' },579 function(res){580 res.headers['set-cookie']581 .should.eql(['rememberme=; expires=Thu, 01 Jan 1970 00:00:00 GMT']);581 .should.eql(['rememberme=; path=/foo; expires=Thu, 01 Jan 1970 00:00:00 GMT']);582 });583 },584 585 'test HEAD': function(){
24 unmodified lines