I thought I knew how cookies work a little but I have doubts now.
- Have a python3 script to run a web browser (Google Chrome, for instance) controlled by Selenium. With
options.add_argument("user-data-dir=<folder_full_path>")
I set a folder for the browser folder. The folder does not exist yet. - Run the script. Read cookies with
driver.get_cookies()
and get an empty list obviously. Stop the script withinput()
- Manually visit www.dw.com; www.paris.com. Each greets me with a message and "have a cookie" button.
- Read cookies with
driver.get_cookies()
again and can see cookies. - Quit the Selenium web browser and quit the Python script.
The Web browser folder is still there.
- Run the Python script again.
driver.get_cookies()
gives an empty list. - Manually visit www.dw.com and www.paris.com They know me and I don't see any cookie messages (greetings).
- Stop Python script, and quit the selenium-driven web-browser. I erase (or rename) the web-browsers folder and repeat actions 1-5.
So, I realize that visited websites remember "me" but when I start a new web browser session I can not read their cookies even though I visited websites before but they exist somehow. Where? How can I read their cookies? Why dw.com and paris.com can see their cookies saved before but I can not?