title: Selenium cookie with another domain
body: <p>I have a code on selenium to test a form. But first i go to another page and then redirect to the my page. When i set cookies to new domain , i got error : </p>
  
  <pre><code>Exception in thread "main" org.openqa.selenium.InvalidCookieDomainException: You may only set cookies for the current domain
  </code></pre>
  
  <p>My Code : </p>
  
  <pre><code>//it is going to example.com and example redirect me to the "example.com" all cookie domains is "example.com"
  driver.get("http://www.example.com?id=1");
  
   Set&lt;Cookie&gt; cookies = driver.manage().getCookies();
   Iterator&lt;Cookie&gt; itr = cookies.iterator();
  
      while (itr.hasNext()){
      Cookie c = itr.next();
      System.out.println("Cookie Name: " + c.getName() + " --- " + "Cookie Domain: " + c.getDomain() + " --- " + "Cookie Value: " + c.getValue());
  
      driver.manage().addCookie(c);
      }
  </code></pre>
  
  <p>How can i manage that ? I have to get/set cookies for example.com</p>