Skip to content

Latest commit

 

History

History
64 lines (40 loc) · 1.42 KB

cookies.rst

File metadata and controls

64 lines (40 loc) · 1.42 KB

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.