此代码在我的localhost上运行良好,但当我尝试在安全(https)服务器上使用它时,cookie永远不会设置。
<?php
error_reporting(0);
if (isset($_COOKIE["count"]))
{
//cheak user refreshes
$cookie = (int)++$_SESSION['count'];
setcookie('count', $cookie, time() + 900, '/');
$PopExitUrl="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&good=1';
}
else
{
setcookie('count', 1, time() + 900, '/');
$PopExitUrl="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&bad=1';
}
?>