Mike,

Just a thought - are you outputting any HTML on the page where you are
declaring your cookie?

If not, then it won't work.

I got stuck a few months back with a filter script where someone logs in and
depending on who they were were redirected to various pages. I was decalring
their cookies in the redirect script and it didn't work until I started
doing in on a 'written' page.

Hope this solves your problem.

Cheers

George in Oxford

> -----Original Message-----
> From: Boaz Yahav [mailto:[EMAIL PROTECTED]
> Sent: 04 July 2003 10:05 am
> To: Mike Morton; [PHP - GENERAL]
> Subject: RE: [PHP] Setting Cookie Going Nuts
>
>
> Did you solve this issue?
> What does $_SERVER["HTTP_HOST"] return?
>
> Sincerely
>
> berber
>
> Visit http://www.weberdev.com/ Today!!!
> To see where PHP might take you tomorrow.
>
>
> -----Original Message-----
> From: Mike Morton [mailto:[EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
> *
> ****************************************************
>
> "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
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to