Re: Setting Cookie Going Nuts
| From: | Mike Morton | Date: | Tue, 08 Jul 2003 14:24:47 +0000 |
| Subject: | Re: Setting Cookie Going Nuts | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-154367@lists.php.net to get a copy of this message | ||
Berber:
> Did you solve this issue?
No, this issue was not resolved.
> What does $_SERVER["HTTP_HOST"] return?
It returns the IP address that is assigned to the website. There is no
domain assigned, just the IP. When there is a domain assigned it would
assign the domain...
>
> Sincerely
>
> berber
>
> Visit http://www.weberdev.com/ Today!!!
> To see where PHP might take you tomorrow.
>
>
> -----Original Message-----
> From: Mike Morton [mailto:mike@webtraxx.com]
> Sent: Thursday, July 03, 2003 4:03 PM
> To: [PHP - GENERAL]
> Subject: [PHP] Setting Cookie Going Nuts
>
>
> I am trying to issue a cookie, using the set cookie directive, and it is
> not working for some reason. The code below I have used before with
> perfect success. The only difference between the other place that I am
> using it is that the other place has globals on, this server has globals
> off (tho I turned them on a and it made no difference), and the other
> server is running 4.3.2 where this one is 4.3.0
>
> I am sure that it is something small that I missed when copying the code
> over, but I cannot for the life of me see what it is. The only other
> difference is the other server is using a domain name, while the server
> this code is on is an IP address only (that should not make a difference
> tho)
>
> Why is the cookie not being isseued? I am going nuts trying to figure
> this out!
>
> $ADMIN_COOKIE_NAME="scavengeradmin"; //name of the issuing cookie
> $COOKIE_EXPIRY=1800; //time in seconds to expiry
>
> function adminCookie() {
> global $ADMIN_COOKIE_NAME,$COOKIE_EXPIRY;
>
> //check to see if a cookie exists already.
> $cookieid=$_COOKIE[$ADMIN_COOKIE_NAME];
>
> //if there is no cookieid - then we are going to set a cookie.
> if(strlen($cookieid) < 1) {
> //find a unique value.
> list($msec,$sec)=explode(" ",microtime());
> $cookiekey=ereg_replace("\.","",($msec+$sec));
> //set expiry - 30 mins from now.
> $cookieexpiry=time()+$COOKIE_EXPIRY;
>
> setcookie($ADMIN_COOKIE_NAME,$cookiekey,$cookieexpiry,"/",$_SERVER["HTTP
> _HOS
> T"],0);
> $_COOKIE[$ADMIN_COOKIE_NAME]=$cookiekey;
> unset($cookiekey);unset($msec);unset($sec);unset($cookieexpiry);
> } else {
> //if the cookie has been set then we are just going to adjust
> the expiry date.
> //set expiry - 30 mins from now.
> $cookieexpiry=time()+$COOKIE_EXPIRY;
>
>
> setcookie($ADMIN_COOKIE_NAME,"$cookieid",$cookieexpiry,"/",$_SERVER["HTT
> P_HO
> ST"],0);
> unset($cookieexpiry);
> }
>
> unset($cookieid);
> }
>
> adminCookie(); //issue the cookie
>
> --
> Cheers
>
> Mike Morton
>
> ****************************************************
> *
> * Tel: 905-465-1263
> * Email: mike@webtraxx.com
> *
> ****************************************************
>
> "Indeed, it would not be an exaggeration to describe the history of the
> computer industry for the past decade as a massive effort to keep up
> with Apple."
> - Byte Magazine
>
> Given infinite time, 100 monkeys could type out the complete works of
> Shakespeare. Win 98 source code? Eight monkeys, five minutes.
> -- NullGrey
>
--
Cheers
Mike Morton
****************************************************
*
* Tel: 905-465-1263
* Email: mike@webtraxx.com
*
****************************************************
"Indeed, it would not be an exaggeration to describe the history of the
computer industry for the past decade as a massive effort to keep up with
Apple."
- Byte Magazine
Given infinite time, 100 monkeys could type out the complete works of
Shakespeare. Win 98 source code? Eight monkeys, five minutes.
-- NullGrey