Re: A setcookie related question
| From: | Frank M. Kromann | Date: | Sun, 04 Sep 2005 20:34:11 +0000 |
| Subject: | Re: A setcookie related question | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-26298@lists.php.net to get a copy of this message | ||
Hi Tony,
In most cases you do not need to use the domain parameter. Try to simplify
the function call to
setcookie("auth", "1", 0, "/"); // Not this cookie has already expired
setcookie("auth", "1", time() + 3600, "/"); // Not this cookie will
expire
in 1 hour
or even to
setcookie("auth", "1"); // Note this wil be a session cookie that wil
expire when the browsr window is closed.
- Frank
> Hi There,
>
>
>
> I am a beginner PHP developer and I have a very simple, perhaps silly,
> question:
>
>
>
> I am trying to use the setcookie function in a PHP script and I seem to
be
> struggling with the "domain" parameter. Here is situation:
>
>
>
> //set authorization cookie
>
> setcookie("auth", "1", 0, "/", "yourdomain.com", 0);
>
>
>
> Instead of the "yourdomain.com" string in this function call I am
suppose to
> use my own domain name, but I do not have a WEB site yet. As a result I
am
> using localhost at the moment. I have tried several values with no
success.
> Since I am running these scripts on my local PC using "i.e. localhost",
what
> should I set this value to?
>
>
>
> I have tried the following combinations with no avail:
>
> setcookie("auth", "1", 0, "/", "localhost", 0);
>
> setcookie("auth", "1", 0, "/", "localhost:8080", 0); (I
> a running
Apache
> HTTP Server 2.0.54 on port 8080)
>
> setcookie("auth", "1", 0, "/", "127.0.0.1", 0);
>
> setcookie("auth", "1", 0, "/", ".oc.cox.net", 0); (this
> is what my
IPCONFIG
> returns as my "connection-specific DNS Suffix".)
>
>
>
> Any help would be greatly appreciated.
>
>
>
> Regards,
>
> Tony Aldemir
>
>
>
>