【发布时间】:2012-03-21 11:02:00
【问题描述】:
这是用户登录后我的代码:
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>
这在我的 wamp 本地主机上不起作用?有什么问题?
【问题讨论】:
-
5 秒的谷歌搜索让我明白了:stackoverflow.com/questions/1134290/…
-
PHP 代码不在 .html 文件中进行评估(默认情况下)。你确定它实际上是在运行而不是直接在页面上输出 PHP 代码吗?
-
请不要将密码存储在cookie中