title: Selenium Chromedriver add cookie - invalid domain error
body: <p>I am trying to store and upload a cookie that I retrieve from a webpage via selenium.</p>
  
  <p>I am new to cookies so please tell me what I am doing wrong. I am trying to learn.</p>
  
  <p>I open a page up with selenium, manually log in, peform some action then wait.. (and my code is set to get cookies after 30 seconds )</p>
  
  <pre><code>print "adding cookies now"
  cookies = pickle.load(open("cookies.pkl", "rb"))
  for cookie in cookies:
      driver.add_cookie(cookie)
  </code></pre>
  
  <p>after that, my cookies.pkl file looks something like this: </p>
  
  <pre><code>(lp0
  (dp1
  Vdomain
  p2
  V.twitter.com
  p3
  sVsecure
  p4
  I00
  sVvalue
  p5
  V"v3:1484006785862560132892059"
  p6
  sVexpiry
  p7
  F1531267585.126113
  sVpath
  p8
  # more lines
  </code></pre>
  
  <p>after this <code>log_in_and_store()</code>, i try to reopen the page with selenium while loading this cookies. If done correctly, it should open to the page i left off! Not the login page. </p>
  
  <p>When I try uploading my cookies to the webpage like this:</p>
  
  <pre><code>driver.get('http://www.website.com')
  cookies = pickle.load(open("cookies.pkl", "rb"))
  for cookie in cookies:
      print cookie
      driver.add_cookie(cookie)
  </code></pre>
  
  <p>add_cookies are throwing this error:</p>
  
  <blockquote>
    <p>selenium.common.exceptions.WebDriverException: Message: invalid cookie
    domain: invalid domain:".twitter.com"   (Session info:
    chrome=55.0.2883.95)   (Driver info: chromedriver=2.24.417412
    (ac882d3ce7c0d99292439bf3405780058fcca0a6),platform=Mac OS X 10.12.1
    x86_64)</p>
  </blockquote>
  
  <p>I tried this already, SO PLEASE DONT LINK ME TO IT(<a href="https://stackoverflow.com/questions/19149034/selenium-addcookie-getting-invalid-cookie-domain-exception-even-though-im-on-th">Selenium addCookie getting Invalid Cookie Domain Exception even though I&#39;m on the right domain</a>)</p>
  
  <p>Ive also tried changing chromedriver versions, changing my code a million times and banging my head against the wall. none of those worked.</p>
  
  <p>Please help, thank you very much</p>