Forum Moderators: coopster
<?php
setcookie("uname", $name, time()+36000);
?><html>
<body><p>
A cookie was set on this page! The cookie will be active when
the client has sent the cookie back to the server.
</p>
<?php
if (isset($_COOKIE["uname"]))
echo "Welcome " . $_COOKIE["uname"] . "!<br />";
else
echo "You are not logged in!<br />";
?>
but it is not working . the else stmt is executed .
any suggestion?
I think there is a problem with my Apache server . when I first wrote in the browser’s address :http://localhost it doesn’t open the index page but after I wrote [localhost...] it open it . I have no idea of what that means .
Do I have any Apache file missing or something? Or there a configuration that I must make to my computer?
Can any body help me?
The index page is issue is related to how you have Apache setup, specifically the DirectoryIndex [httpd.apache.org]. That whole page is a short read and really good read -- should help you understand a bit more about the HTTP server.
As far as your cookie goes, have a closer read on the PHP manual page for setcookie() [php.net]:
Once the cookies have been set, they can be accessed on the next page load ...
Hope this helps!