Handle Cookies

It is possible to manipulate cookies using the cookies attribute from a Browser instance. The cookies attribute is an instance of the CookieManager class that manipulates cookies (ie: adding and deleting).

browser.cookies.add({'cookie_name': 'cookie_value'})

Retrieve all cookies

cookies = browser.cookies.all()
browser.cookies.delete('cookie_name')  # delete the cookie 'cookie_name'
browser.cookies.delete('cookies_name_1', 'cookies_name_2')  # delete two cookies

Delete all cookies


For more details check the API reference of the CookieManager class.

Extra Arguments

Each driver accepts various parameters when creating cookies. These can be used with browser.cookies.add as extra arguments. For example, WebDriver can use path, domain, secure, and expiry:


browser.cookies.add({‘cookie_name’: ‘cookie_value’}, path=’/cookiePath’)