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["HTTP_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

Reply via email to