title: Selenium and Google - How do you use cookies?
body: <p>I am currently building a reporting tool with Selenium on Adwords. (And no, I cannot use Google's API because it doesn't provide the functionality I want). </p>
  
  <p>I am trying to avoid logging in and logging out, because I understand frequent logins and logouts are not as convenient as cookie based authentication. </p>
  
  <p>I have the following code: save.py</p>
  
  <pre><code>try:
    driver = webdriver.Chrome()
    driver.get('https://adwords.google.com')
    time.sleep(90)
    # Manually login to adwords page and wait
    pickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))
  
  finally:
    driver.close()
  </code></pre>
  
  <p>And this: load.py</p>
  
  <pre><code>try:
    driver = webdriver.Chrome()
    cookies = pickle.load(open("cookies.pkl", "rb"))
    for cookie in cookies:
      driver.add_cookie(cookie)
  
    driver.get('https://adwords.google.com/')
    time.sleep(60)
  
  finally:
    driver.close()
  </code></pre>
  
  <p>When I first run load.py, I am actually able to see the spinner that shows up when one logs into Adwords. Shortly after however, I get logged out!</p>
  
  <p>I don't know what is causing Google's authentication system to log me out. What do you think is the cause of this? </p>
  
  <p>Code Repo: <a href="https://gist.github.com/anonymous/63d32e49f59a09ab82fac1f9f972d555" rel="nofollow noreferrer">https://gist.github.com/anonymous/63d32e49f59a09ab82fac1f9f972d555</a> </p>