What information about device does cookie store?

夙愿已清 提交于 2020-03-16 09:52:47

问题


I'm using selenium to collect cookies, and here's the question: does cookies store information about selenium?


回答1:


You can check the cookies list by driver.manage().getCookies(); Return type is Set <Cookies>.

Hope this will help.




回答2:


No, cookies doesn't store information about Selenium.


Cookies

As per the article Privacy Concerns on Cookies, cookies are harmless. In it's basic form, cookies are simple uncompiled text files that help coordinate the remote website servers and your browser to display the full range of features offered by the websites. These features may include hassle-free automatic logins and authentication, third party ad serving, ad management, preference settings, language settings, etc.


Tracking User Behavior

While cookies by themselves cannot dig or research your information or search your computer, they do store personal information in at least two ways:

  • Form information and
  • Ad tracking

This personal information is not generated by the cookies themselves but by your own input into website order forms, registration pages, payment pages, and other online forms.


Demonstration

A simple example to demonstrate the information stored by cookies using pickle is as follows:

  • Code Block:

    import pickle
    import selenium.webdriver 
    import time
    
    driver = selenium.webdriver.Firefox()
    driver.get("http://www.google.com")
    pickle.dump( driver.get_cookies() , open(r'C:\Utility\testdata\my_cookies.pickle',"wb"))
    driver.quit()
    pickle_off = open(r'C:\Utility\testdata\my_cookies.pickle',"rb")
    personOut = pickle.load(pickle_off)
    print(list(personOut))
    
  • Console Output:

    [{'name': '1P_JAR', 'value': '2020-02-21-14', 'path': '/', 'domain': '.google.com', 'secure': True, 'httpOnly': False, 'expiry': 1584888349}, {'name': 'NID', 'value': '198=DCEMsfy3h6nZ0vpi6p3m3J-vVJpDlUBc7ItYE99kbFtr2fssl-1nVVXqF6joPREjrW-X8yxe5PnDqMNiVaVUd0NY8S_YOfksQdb-SzKSPUP5XumjlTjyTt_C8a5XSOmpUuXnOu-JCXHDe71fTe2KC-0kwb5B7_N7wSzM6Jrozqs', 'path': '/', 'domain': '.google.com', 'secure': True, 'httpOnly': True, 'expiry': 1598107549}]
    


来源:https://stackoverflow.com/questions/60362601/what-information-about-device-does-cookie-store

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!