下面的代码:在chrome和firefox下可以生成三个cookie:
cookie[one]、cookie[two]、cookie[three]
在IE下,只能生成cookie[one]、cookie[two]两个cookie,第三个因为指定了”.65.la”,导致cookie[three]生成失败。
setcookie(“cookie[one]“, “cookieone”,time()+36000,”/”);
setcookie(“cookie[two]“, “cookietwo”,time()+36000,”/”);
setcookie(“cookie[three]“, “cookiethree”, time()+36000,”/”,”.65.la”);
// 页面重新
if (isset($_COOKIE["cookie"])) {
foreach ($_COOKIE["cookie"] as $name => $value) {
$name = htmlspecialchars($name);
$value = htmlspecialchars($value);
echo “$name : $value
\n”;
}
}
?>
多次实验之后,确认IE认为”.65.la”这种形式的域名参数是不规范的。如果要cookie在所有子域名通用的话,可以通过全局变量来变通的实现。
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn