MCPcopy
hub / github.com/psf/requests / remove_cookie_by_name

Function remove_cookie_by_name

src/requests/cookies.py:164–182  ·  view source on GitHub ↗

Unsets a cookie by name, by default over all domains and paths. Wraps CookieJar.clear(), is O(n).

(
    cookiejar: CookieJar, name: str, domain: str | None = None, path: str | None = None
)

Source from the content-addressed store, hash-verified

162
163
164def remove_cookie_by_name(
165 cookiejar: CookieJar, name: str, domain: str | None = None, path: str | None = None
166) -> None:
167 """Unsets a cookie by name, by default over all domains and paths.
168
169 Wraps CookieJar.clear(), is O(n).
170 """
171 clearables: list[tuple[str, str, str]] = []
172 for cookie in cookiejar:
173 if cookie.name != name:
174 continue
175 if domain is not None and domain != cookie.domain:
176 continue
177 if path is not None and path != cookie.path:
178 continue
179 clearables.append((cookie.domain, cookie.path, cookie.name))
180
181 for domain, path, name in clearables:
182 cookiejar.clear(domain, path, name)
183
184
185class CookieConflictError(RuntimeError):

Callers 2

setMethod · 0.85
__delitem__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected