Hi all - I am having a problem with cookies. It seems that if I set the domain field in setcookie, nothing happens. I also tried creating the cookie header manually, with the same results. This is what I have:
$expireTime = time(); $expireTime += ($daysToExpire * 86400);
setcookie("Test1", "Thistest"); setcookie("Test2", "Thistest", $expireTime); setcookie("Test3", "Thistest", $expireTime, "/"); setcookie("Test4", "Thistest", $expireTime, "/", ""); setcookie("Test5", "Thistest", $expireTime, "/", ".mydomain.com.");
$COOKIE = "Set-Cookie: $cookieName=$cookieValue"; $COOKIE .= "; expires=" . gmdate("D, d-M-Y H:i:s", $expireTime) . " GMT "; $COOKIE .= "; path=/"; $COOKIE .= "; domain=.mydomain.com.; header ($COOKIE, false);
When I run this page in my browser, I get asked if I want to allow cookies Test1 through Test4, but not Test5 and Test6 - they just don't get written.
I have a perl script that does the same thing as the manual version, I have matched up character-by-character the string in $COOKIE with what is printed out by perl, but the perl works and the php doesn't.
Any clues?
thanks, andy
--- Begin Message ---Because you are not subscribed to "[EMAIL PROTECTED]" using the email address "[EMAIL PROTECTED]", your message has been held until you can confirm that you are a real person sending mail.All you have to do in order to have your original message sent is send an email to [EMAIL PROTECTED] with the following text (square brackets and all): [confirm: cbb8c14c0b707baf9027a5269d5e0149 [EMAIL PROTECTED] which you should be able to do simply by responding to this email. (Don't worry, any leading text added for quoting will simply be ignored.) After we have received your confirmation, "[EMAIL PROTECTED]" will be added to the list of pre-approved mail addresses for all of the PHP mailing lists, your original message will be delivered, and future emails from that address will be posted to the list automatically. You will not receive any confirmation of your confirmation -- your original message (and any other messages you have sent since then) will simply be sent to its original destination (possibly after a short delay). Sorry for the hassle, but the volume of unsolicited commercial email sent to PHP mailing lists has made this step necessary. (Note that the newsgroups available at news://news.php.net/ are simply gateways to the mailing lists, which is why you may have gotten this email as a result of posting to those newsgroups.) --- Your original email is below. Received: (qmail 72936 invoked from network); 14 Mar 2003 02:14:21 -0000 Received: from unknown (HELO globilltech.com) (209.61.182.14) by pb1.pair.com with SMTP; 14 Mar 2003 02:14:21 -0000 Received: from globilltech.com (astound-64-85-231-125.ca.astound.net [64.85.231.125]) by globilltech.com (8.9.3/8.9.3) with ESMTP id SAA07152 for <[EMAIL PROTECTED]>; Thu, 13 Mar 2003 18:17:55 -0800 Message-ID: <[EMAIL PROTECTED]> Date: Thu, 13 Mar 2003 18:13:55 -0800 From: Andrew Wallace <[EMAIL PROTECTED]> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: [EMAIL PROTECTED] Subject: Strange cookie issue Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi all - I am having a problem with cookies. It seems that if I set the domain field in setcookie, nothing happens. I also tried creating the cookie header manually, with the same results. This is what I have: $expireTime = time(); $expireTime += ($daysToExpire * 86400); setcookie("Test1", "Thistest"); setcookie("Test2", "Thistest", $expireTime); setcookie("Test3", "Thistest", $expireTime, "/"); setcookie("Test4", "Thistest", $expireTime, "/", ""); setcookie("Test5", "Thistest", $expireTime, "/", ".mydomain.com."); $COOKIE = "Set-Cookie: $cookieName=$cookieValue"; $COOKIE .= "; expires=" . gmdate("D, d-M-Y H:i:s", $expireTime) . " GMT "; $COOKIE .= "; path=/"; $COOKIE .= "; domain=; header ($COOKIE, false); When I run this page in my browser, I get asked if I want to allow cookies Test1 through Test4, but not Test5 and Test6 - they just don't get written. I have a perl script that does the same thing as the manual version, I have matched up character-by-character the string in $COOKIE with what is printed out by perl, but the perl works and the php doesn't. Any clues? thanks, andy
--- End Message ---
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php