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

Instruct browser to remove cookies #563

Closed
wants to merge 4 commits into from

Conversation

Freezerburn
Copy link
Contributor

fix: Cookies not being removed from browser

The previous behavior of Response's unset_cookie function was just to delete the given name from the SimpleCookie object if it existed. However, this causes a problem in that the browser is not told to remove the cookie on its side, causing all future Request objects to still contain the cookie that was supposed to have been unset/removed. This change causes the Response object to actually set the expires token for the cookie that is being unset to a point in the past, causing the browser to immediately remove the now-expired cookie, which will remove the cookie from future Request objects.

The previous behavior of Response's unset_cookie function was just to delete the given name from the SimpleCookie object if it existed. However, this causes a problem in that the browser is not told to remove the cookie on its side, causing all future Request objects to still contain the cookie that was supposed to have been unset/removed. This change causes the Response object to actually set the expires token for the cookie that is being unset to a point in the past, causing the browser to immediately remove the now-expired cookie, which will remove the cookie from future Request objects.
Docstring now mentions that the browser's copy of a cookie will be expired when using the unset_cookie method.
@Freezerburn
Copy link
Contributor Author

@kgriffs The docstring has been expanded. Let me know if the explanation is satisfactory.

del self._cookies[name]
if self._cookies is None:
self._cookies = SimpleCookie()
if name not in self._cookies:
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to always set the value to the empty string, even if it was set elsewhere in the app to some value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That actually does make sense. I'll make that change.

@kgriffs
Copy link
Member

kgriffs commented Jul 16, 2015

The docstring has been expanded.

Looks good, thanks!

Instead of having a branch checking for if the cookie already exists, just wipe out the existing value with the blank string. The intention is to remove the cookie, so there's no reason to preserve a previous value.
As per how comments are handled for Falcon: a newline is before the large comment and the "NOTE" tag has been added.
@kgriffs
Copy link
Member

kgriffs commented Aug 3, 2015

@Freezerburn Looks good. As a final step in preparation for merging, could you please rebase on master and squash down to a single commit, formatted according to our style guide? Thanks!

@kgriffs
Copy link
Member

kgriffs commented Sep 17, 2015

@Freezerburn I think this is ready to go, but it needs to be rebased first.

@kgriffs
Copy link
Member

kgriffs commented Oct 16, 2015

Manually rebased and resubmitted as #634

@kgriffs
Copy link
Member

kgriffs commented Oct 16, 2015

[merged via #634]

@kgriffs kgriffs closed this Oct 16, 2015
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.

None yet

2 participants