Home  >  Article  >  Backend Development  >  After PHP setcookie specifies the domain parameter, the solution to the invalid cookie setting under IE_PHP tutorial

After PHP setcookie specifies the domain parameter, the solution to the invalid cookie setting under IE_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:24:32968browse

The following code: Three cookies can be generated under chrome and firefox:
cookie[one], cookie[two], cookie[three]
Under IE, only cookie[one], cookie[two] can be generated ] two cookies, the third cookie failed to be generated because ".65.la" was specified.

Copy code The code is as follows:

setcookie("cookie[one]", "cookieone ",time()+36000,"/");
setcookie("cookie[two]", "cookietwo",time()+36000,"/");
setcookie("cookie[three] ", "cookiethree", time()+36000,"/",".65.la");
// Page reset
if (isset($_COOKIE["cookie"])) {
foreach ($_COOKIE["cookie"] as $name => $value) {
$name = htmlspecialchars($name);
$value = htmlspecialchars($value);
echo “$ name : $value
n”;
}
}
?>

After many experiments, it was confirmed that IE thinks “.65.la” This form of domain name parameter is not standardized. If you want the cookie to be common to all subdomains, you can implement it through global variables.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324274.htmlTechArticleThe following code: three cookies can be generated under chrome and firefox: cookie[one], cookie[two] , cookie[three] Under IE, only two cookies, cookie[one] and cookie[two], can be generated. The third reason...
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