setcookie函数指定domain参数后,在IE下的表现和在chrome、firefox中的表现不同,这不是php setcookie函数的问题,这是IE的问题。
下面的代码:在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在所有子域名通用的话,可以通过全局变量来变通的实现。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.