Forum Moderators: coopster

Message Too Old, No Replies

am I having an Apache problem

         

redweb

5:38 pm on Mar 10, 2006 (gmt 0)



This is a cookie code :


<?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?

phparion

5:53 pm on Mar 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



are you using windows or linux?

check your cookies settings in php.ini too, sometimes its not working from there.

redweb

6:08 pm on Mar 10, 2006 (gmt 0)



I'm using windows.
I have no idea about using php.ini
can you help me.

coopster

9:48 pm on Mar 10, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, redweb.

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!

redweb

5:48 pm on Mar 11, 2006 (gmt 0)



I read about DirectoryIndex.but I didn't understand it very well.
thank you all for your replays.

coopster

5:51 pm on Mar 11, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



DirectoryIndex says, "look for files with this name in the directory, if you find one, display it." If the HTTP server can't find one with any of the names specified in that directive in your server's httpd.conf file it will see if a directory listing is allowed. If it is, it will show a list of the files in that directory, otherwise it will serve up an error message.