title: How to reliably set cookies on localhost using webdriver and Chrome?
body: <p>In my experience, this works fine when using webdriver (via Protractor) to inject a cookie into a browser session on Firefox:</p>
  
  <pre><code>browser.manager().addCookie(...)
  </code></pre>
  
  <p>Where the "..." is an "httpOnly" localhost session cookie used to indicate that a user is logged in.</p>
  
  <p>The same code when run against a Chrome browser (using the direct ChromeDriver) does not work.  First, there are the localhost cookie exceptions:</p>
  
  <pre><code>Message:
       InvalidCookieDomainError: invalid cookie domain: invalid domain:"localhost"
    (Session info: chrome=41.0.2272.89)
    (Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 3.13.0-45-generic x86_64)
     Stacktrace:
       InvalidCookieDomainError: invalid cookie domain: invalid domain:"localhost"
    (Session info: chrome=41.0.2272.89)
    (Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 3.13.0-45-generic x86_64)
  </code></pre>
  
  <p>Even if I can work-around the localhost problem (E.g., by setting fully qualified domain), Chrome will just ignore my changes to the cookie.</p>
  
  <p>I'm running on Linux, with Protractor 2.0.0, and google-chrome 41.0.xxx and chromedriver 2.14.</p>