Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

removeCookie may block subsequent cookie writes if options are cached in the calling code #175

Closed
givankin opened this issue Mar 29, 2013 · 1 comment
Assignees

Comments

@givankin
Copy link

The thing is that options object is extended in removeCookie with {expires: -1}.

Imagine the following code:

var options = { path: myPath, domain: myDomain }
// Then somewhere in the code:
$.cookie(key, value, options)
// And then somewhere in another place:
$.removeCookie(key, options)
// At this moment our options are extended with {expires:-1}, so:
$.cookie(key, value, options) 
$.cookie(key) // undefined: it expired right when we wrote it!

The fix is to extend options in removeCookie the same way it's done on writing:

// Bad:
$.cookie(key, '', $.extend(options, { expires: -1 }));
// Good:
$.cookie(key, '', $.extend({}, options, { expires: -1 }));

Sorry for no pull request.

@carhartl
Copy link
Owner

Yeah right!

@ghost ghost assigned carhartl Mar 29, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants