flask-login
flask-login copied to clipboard
Clear Cookie needs SameSite and Secure attributes
Describe the bug
We need to provide SameSite and Secure attributes when we clear cookie also as some browsers (Example, Brave) not clearing the cookie without SameSite: None
and Secure
attributes as they are needed for CORS
.
To Reproduce Steps to reproduce the behavior:
- Login using flask-login with remember me as true
- Verify that if remember me cookie is set
- Logout
- Verify that if remember me cookie is cleared or not
- In my case it's not
Expected behavior Remember cookie should be cleared
Screenshots
BRAVE BROWSER:
CHROME BROWSER:
def _set_cookie(self, response):
....
response.set_cookie(
cookie_name,
value=data,
expires=expires,
domain=domain,
path=path,
secure=secure,
httponly=httponly,
samesite=samesite,
)
def _clear_cookie(self, response):
...
response.delete_cookie(cookie_name, domain=domain, path=path)
We are sending SameSite
and Secure
when we _set_cookie
but not in _clear_cookie
.
Desktop (please complete the following information):
- Device: Laptop
- OS: Pop! OS
- Browser: Brave, Chrome
- Version: 103
Additional context
If this is still an issue then please address it with a proposed fix in the form of a PR.