无法在 Internet Explorer 中从深度嵌套的域名设置 COOKIE


Can't set a COOKIE in Internet Explorer from a deeply nested domain name

我的本地开发沙盒可以通过这样的 URL 访问:

http://hello.trunk.world.dev.foobar.local/

当我尝试从这里设置cookie时,它适用于所有浏览器,除了Internet Explorer(版本10及更低版本)。有没有办法让它工作?

setcookie('myCookieName', 'myCookieValue', time()+3600, '/', '.foobar.local');
var_dump($_COOKIE); // Shows nothing in IE, shows the cookie in other browsers

这是IE实际上按照标准行事的情况之一。下划线在域名中无效,这就是 Cookie 不适用于无效域名的原因。