Disabling cookies for IP addresses and localhost
was a design decision. See also: https://code.google.com/p/chromium/issues/detail?id=56211
Ways to work around the issue include:
- Set a local domain (e.g., edit
/etc/hosts
to use127.0.0.1 localhost.com
). - Use http://myproject.localhacks.com/ (which points to 127.0.0.1).
- Use an empty domain value when setting the cookie.
For example, in PHP:
setcookie(
$AUTH_COOKIE_NAME,
$cookie_value,
time() + cookie_expiration(),
$BASE_DIRECTORY,
null,
false,
true
);
Here the value null
indicates that the domain should not be set.
Note: not setting the domain prevents the cookie being visible to sub-domains.