[英]PHP setcookie doesn't work on IE8
the following code doesn't work on IE8. 以下代码在IE8上不起作用。 i tried print_r ($_COOKIE) but it returned array(); 我尝试了print_r($ _COOKIE),但是它返回了array(); please help me. 请帮我。
1 <?php
2 $currentTime = time();
3
4 $cookieName = "go.hyde";
5 $cookiePath = "/";
6 $cookieDomain = $_SERVER['SERVER_NAME'];
7 $cookieValue = strval($currentTime); // value is issue time (Unix Time)
8 $cookieExpire = strval($currentTime + 600); // expire is 10 minutes after issuing cookie
9
10 setcookie($cookieName,
11 $cookieValue,
12 $cookieExpire,
13 $cookiePath,
14 $cookieDomain);
15
try without cookie path and cookie domain 尝试不使用Cookie路径和Cookie域
setcookie($cookieName,$cookieValue,$cookieExpire);
check if cookies are enabled in IE 检查是否在IE中启用了cookie
============== EDIT ================ =============编辑================
I think I got it, try this: 我想我明白了,试试看:
<?
$currentTime = time();
$cookieName = "gohyde";
$cookieValue = strval($currentTime); // value is issue time (Unix Time)
$cookieExpire = strval($currentTime + 600); // expire is 10 minutes after issuing cookie
setcookie($cookieName,
$cookieValue,
$cookieExpire);
echo $_COOKIE[$cookieName];
?>
without cookie path and cookie domain. 没有Cookie路径和Cookie域。 and no "." 和不 ”。” dot in the cookie name. Cookie名称中加点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.