Tree @master (Download .tar.gz)
- ..
- _static
- _templates
- api
- contribute
- drivers
- news
- browser.rst
- community.rst
- conf.py
- contribute.rst
- cookies.rst
- elements-in-the-page.rst
- finding.rst
- http-proxies.rst
- http-status-code-and-exception.rst
- iframes-and-alerts.rst
- index.rst
- install.rst
- javascript.rst
- make.bat
- Makefile
- matchers.rst
- mouse-interaction.rst
- news.rst
- screenshot.rst
- selenium-keys.rst
- tutorial.rst
- why.rst
cookies.rst @master — view markup · raw · history · blame
Cookies manipulation
It is possible to manipulate cookies using the cookies attribute from a Browser instance. The cookies attribute is a instance of a CookieManager class that manipulates cookies, like adding and deleting them.
Create cookie
To add a cookie use the add method:
browser.cookies.add({'whatever': 'and ever'})
Retrieve all cookies
To retrieve all cookies use the all method:
browser.cookies.all()
Delete a cookie
You can delete one or more cookies with the delete method:
browser.cookies.delete('mwahahahaha') # deletes the cookie 'mwahahahaha' browser.cookies.delete('whatever', 'wherever') # deletes two cookies
Delete all cookies
You can also delete all cookies: just call the delete method without any parameters:
browser.cookies.delete() # deletes all cookies
For more details check the API reference of the :class:`CookieManager <splinter.cookie_manager.CookieManagerAPI>` class.