Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Cookie在本地主机上工作吗?_Php_Html_Cookies - Fatal编程技术网

Php Cookie在本地主机上工作吗?

Php Cookie在本地主机上工作吗?,php,html,cookies,Php,Html,Cookies,可能重复: 这是用户登录后的我的代码: 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>

可能重复:

这是用户登录后的我的代码:

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本地主机上不起作用?有什么问题吗?

是的,它们在本地主机上工作。创建一个域并将其插入/etc/hosts。在我的电脑上,我有C:\Windows\System32\drivers\etc和许多用于开发的主机。

httpd.conf

<VirtualHost *:80>
  ServerName wibble.com
  DocumentRoot "some directory"
<VirtualHost>

<Directory "the same directory">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
主机(
C:\Windows\System32\drivers\etc

添加适当的行

例如


5秒钟的谷歌搜索让我明白:PHP代码不会在.html文件中计算(默认情况下)。你确定它是在运行,而不是直接在页面上输出PHP代码吗?请不要将密码存储在Cookie中为什么不工作?我的代码有问题吗?请确保配置正确,并更改扩展名。
LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"
127.0.0.1   myhost.wibble.com