Delete a cookie if it exists. Cookies are uniquely identified by ``(domain, path, key)``. :param key: The decoded form of the key for the cookie. :param domain: The domain the cookie was set for. :param path: The path the cookie was set for. .. versionchange
(
self,
key: str,
*,
domain: str = "localhost",
path: str = "/",
)
| 902 | self._cookies[cookie._storage_key] = cookie |
| 903 | |
| 904 | def delete_cookie( |
| 905 | self, |
| 906 | key: str, |
| 907 | *, |
| 908 | domain: str = "localhost", |
| 909 | path: str = "/", |
| 910 | ) -> None: |
| 911 | """Delete a cookie if it exists. Cookies are uniquely identified by |
| 912 | ``(domain, path, key)``. |
| 913 | |
| 914 | :param key: The decoded form of the key for the cookie. |
| 915 | :param domain: The domain the cookie was set for. |
| 916 | :param path: The path the cookie was set for. |
| 917 | |
| 918 | .. versionchanged:: 3.0 |
| 919 | The ``server_name`` parameter is removed. The first parameter is |
| 920 | ``key``. Use the ``domain`` parameter instead. |
| 921 | |
| 922 | .. versionchanged:: 3.0 |
| 923 | The ``secure``, ``httponly`` and ``samesite`` parameters are removed. |
| 924 | |
| 925 | .. versionchanged:: 2.3 |
| 926 | The ``domain`` parameter defaults to ``localhost``. |
| 927 | """ |
| 928 | if self._cookies is None: |
| 929 | raise TypeError( |
| 930 | "Cookies are disabled. Create a client with 'use_cookies=True'." |
| 931 | ) |
| 932 | |
| 933 | self._cookies.pop((domain, path, key), None) |
| 934 | |
| 935 | def _add_cookies_to_wsgi(self, environ: WSGIEnvironment) -> None: |
| 936 | """If cookies are enabled, set the ``Cookie`` header in the environ to the |