| 288 | return self.set_cookie(key, value, **kwargs) |
| 289 | |
| 290 | def delete_cookie(self, key, path="/", domain=None, samesite=None): |
| 291 | # Browsers can ignore the Set-Cookie header if the cookie doesn't use |
| 292 | # the secure flag and: |
| 293 | # - the cookie name starts with "__Host-" or "__Secure-", or |
| 294 | # - the samesite is "none". |
| 295 | secure = key.startswith(("__Secure-", "__Host-")) or ( |
| 296 | samesite and samesite.lower() == "none" |
| 297 | ) |
| 298 | self.set_cookie( |
| 299 | key, |
| 300 | max_age=0, |
| 301 | path=path, |
| 302 | domain=domain, |
| 303 | secure=secure, |
| 304 | expires="Thu, 01 Jan 1970 00:00:00 GMT", |
| 305 | samesite=samesite, |
| 306 | ) |
| 307 | |
| 308 | # Common methods used by subclasses |
| 309 | |