Cookie是否适用于本地主机?

时间:2012-03-02 23:28:49

标签: php html cookies

  

可能重复:
  Cookies on localhost with explicit domain

这是用户登录后的代码:

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

2 个答案:

答案 0 :(得分:2)

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>

LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"

主持人(C:\Windows\System32\drivers\etc

添加适当的行

例如

127.0.0.1   myhost.wibble.com

答案 1 :(得分:0)

是的,他们在localhost上工作。组成一个域并将其打入/ etc / hosts。在我的电脑上,我有C:\ Windows \ System32 \ drivers \ etc,有许多主机可供开发。