-7

Possible Duplicate:
Cookies on localhost with explicit domain

this is my code after the user has logged in:

setcookie("user",$entered_username, time()+(60*60*5));
    setcookie("password",$entered_password, time()+(60*60*5));
    header('Location: frontpage.html');

This is my code on frontpage.html:

<!DOCTYPE HTML>
<html>
<head>
<?php
if (isset($_COOKIE["user"]))
  echo $_COOKIE["user"] ;
else
  echo "Welcome guest";
?>
</head>
<body>

</body>
</html>

This does not work on my wamp local host? what is the problem?

Community
  • 1
  • 1
user1244153
  • 85
  • 1
  • 3
  • 7
  • 2
    5 seconds of googling got me: http://stackoverflow.com/questions/1134290/cookies-on-localhost-with-explicit-domain – Zipper Mar 02 '12 at 23:31
  • 2
    PHP code isn't evaluated inside .html files (by default). Are you sure it's actually running rather than just outputting the PHP code directly on the page? – pjumble Mar 02 '12 at 23:32
  • 3
    Please don't store the password in a cookie – Mike B Mar 02 '12 at 23:34

2 Answers2

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>

And

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

hosts (C:\Windows\System32\drivers\etc)

add an appropriate line

eg.

127.0.0.1   myhost.wibble.com
Ed Heal
  • 59,252
  • 17
  • 87
  • 127
0

Yes they work on localhost. Make up a domain and bung it into /etc/hosts. On my PC I have C:\Windows\System32\drivers\etc with a host of hosts for development.

Ed Heal
  • 59,252
  • 17
  • 87
  • 127