From:             [EMAIL PROTECTED]
Operating system: SunOS
PHP version:      4.2.1
PHP Bug Type:     Unknown/Other Function
Bug description:  cookies not set with CGI server API

When I set a cookie with the setcookie command AFTER I requested the value
of an nonexisting cookie (so NULL) with a different name it does not set
the cookie.

I tested it on multiple systems with PHP 4.2.1 installed. On 2 systems it
did not go well and 1 system it has no problem and works fine. The only
difference that I can see is that the "good" system has Apache as "Server
API" and the other 2 "bad" system have CGI as server API.

I ran the following script for the first time with no active cookies set:

<?php
$existing_cookie = $_COOKIE["existing_cookie"];
$value = "test";
if (setcookie ("existing_cookie", $value)) {
        print ("cookie set");
} else {
        print ("cookie NOT set");
}
print (" , existing cookie value: $existing_cookie");
?>

outputs: "cookie NOT set , existing cookie value: "

When I delete the 1st line ($existing_cookie =
$_COOKIE["existing_cookie"];)

and run the script again I get as output: "cookie set , existing cookie
value: "

Then I add the 1st line again ($existing_cookie =
$_COOKIE["existing_cookie"];)

and run the script again and get as output:

"cookie set , existing cookie value: test"

and everything works perfectly even whenever I change the $value.

When I add the next line to the script (at line 2) it does not correctly
set the cookie again.
$existing_cookie2 = $_COOKIE["existing_cookie2"];

-- 
Edit bug report at http://bugs.php.net/?id=19662&edit=1
-- 
Try a CVS snapshot:  http://bugs.php.net/fix.php?id=19662&r=trysnapshot
Fixed in CVS:        http://bugs.php.net/fix.php?id=19662&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=19662&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=19662&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=19662&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=19662&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=19662&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=19662&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=19662&r=submittedtwice
register_globals:    http://bugs.php.net/fix.php?id=19662&r=globals

Reply via email to