Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4] Deprecate res.clearCookie accepting options.maxAge and options.expires #5672

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

jonchurch
Copy link
Member

@jonchurch jonchurch commented May 18, 2024

closes #5640

Adds a deprecation notice when users pass a truthy value in options for maxAge or expires when calling res.clearCookie(name, options).

example:

res.clearCookie: Passing "options.maxAge" is deprecated and should be removed. Starting with the next major release of Express, this option will be ignored, as res.clearCookie will automatically set cookies to expire immediately. Please update your code to omit this option.

Related #4852

lib/response.js Outdated Show resolved Hide resolved
lib/response.js Outdated Show resolved Hide resolved
@jonchurch jonchurch requested a review from wesleytodd May 25, 2024 22:22
@@ -822,6 +822,14 @@ res.get = function(field){
*/

res.clearCookie = function clearCookie(name, options) {
if (options) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to make a comment on this again lol, take this as a nitpick, but if these checks were just made below line 833 they could assume opts and just be the individual if's.

@@ -822,6 +822,14 @@ res.get = function(field){
*/

res.clearCookie = function clearCookie(name, options) {
if (options) {
if (options.maxAge) {
deprecate('res.clearCookie: Passing "options.maxAge" is deprecated and should be removed. Starting with the next major release of Express, this option will be ignored, as res.clearCookie will automatically set cookies to expire immediately. Please update your code to omit this option.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call out v5.0.0 here so that we can be sure to not accidentally miss confusing folks in the future who may not know this was landed in v4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v4] Deprecate res.clearCookie taking maxAge and expires parameters
2 participants