A cookie is a message given to the web browser by a web server. This lets your web browser store information like login information, username, shopping cart and more. The website needs to remember this between different pages, cookies are sometimes used for this.
In selenium you can get and set cookies with the methods get_cookies() and add_cookie().
Related course:
selenium cookies
The selenium cookies code below gets all the cookies set by the site reddit.
1 | # -*- coding: utf-8 -*- |
selenium add delete cookies
The selenium code below gets cookies, then adds a new cookie, gets them again (to show) and finally deletes them.
1 | # -*- coding: utf-8 -*- |
If you are new to selenium, then I highly recommend this book.