可能重复:
Cookies on localhost with explicit domainCookie在本地主机上工作吗?
这是我的代码在用户登录后:
setcookie("user",$entered_username, time()+(60*60*5));
setcookie("password",$entered_password, time()+(60*60*5));
header('Location: frontpage.html');
这是我在frontpage.html代码:
<!DOCTYPE HTML>
<html>
<head>
<?php
if (isset($_COOKIE["user"]))
echo $_COOKIE["user"] ;
else
echo "Welcome guest";
?>
</head>
<body>
</body>
</html>
这不适用于我的本地主机?问题是什么?
5谷歌搜索的秒了我: http://stackoverflow.com/questions/1134290/cookies-on-localhost-with-explicit-domain – Zipper 2012-03-02 23:31:57
PHP代码没有内部.html文件评估(由默认)。你确定它确实在运行,而不是直接在页面上输出PHP代码吗? – pjumble 2012-03-02 23:32:11
请不要将密码保存在cookie中 – 2012-03-02 23:34:58