LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   setcookie failed using host:: 'localhost' (https://www.linuxquestions.org/questions/linux-newbie-8/setcookie-failed-using-host-localhost-633446/)

hil4d 04-06-2008 10:04 AM

setcookie failed using host:: 'localhost'
 
hello

I cannot get setcookie to work when using this code in php:

setcookie("auth", "1", 0, "/", "localhost", 0);

when I replace localhost with an empty string like this:

setcookie("auth", "1", 0, "/", "", 0);

everything works fine.

What is the cause this?

marquardl 04-06-2008 02:40 PM

domain
 
Localhost is a reference for a computer system to it's own webserver. Why would you need cookies for that?

For a public webserver use your fully qualified domain name. Having the '.' (dot) before the domain name seems to help with certain browsers.

Maybe you should try ".localhost" or ".localhost.localdomain" if it's only for local testing.

Leaving the domain field empty obviously works - making the cookie available to the entire Internet, I guess.


Bye,
M

Linux Archive


All times are GMT -5. The time now is 09:25 AM.