【发布时间】:2011-06-16 01:03:17
【问题描述】:
我正在学习 PHP,并尝试根据是否设置了 cookie 来重定向页面,所以下面是我用来在 首页
上设置 cookie 的代码<?php
setcookie("test","logged in",time()+60,'/');
?>
现在在测试页面上我删除了 cookie 但它没有被删除 下面是代码
<?php
setcookie("test", 0, time()-(60*60*24*7));
if(isset($_COOKIE['test']))
{
echo "u had logged in";
}
else
header("Location: index.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
到底是什么问题?
【问题讨论】:
标签: php cookies redirect header