From: webmaster at microwebsolutions dot com Operating system: Windows NT 5 (IIS 4+) PHP version: 4.3.2 PHP Bug Type: Strings related Bug description: COOKIE BUG - VAR NAME IN NAME FIELD CUTS OFF AT A VALUE IF ANY WHEN OUTPUT.
Description: ------------ Cookies: I found that you can use multiple cookies, but a bug is preventing me from numbering my cookies using a counter. Example: setcookie("This_1_cookie","Testing 1"); As you can see here, the "1" represents a counter, but in this case, there are no $variables in its place; this will output perfect. Now, take a number or any string with a number in it, and pop it in there. $i = 1; $MyCookieName="This_$i_cookie"; setcookie($MyCookieName,"Testing 1"); If you have done exactly as above, you will see the following name in your Cookie file: This_ It cuts off right before the number.. But if you tried the one at the top, you will notice the entire string is there. Why is this an issue? Reproduce code: --------------- $NewCount=CartCount+1; # NewCount should be 1 now.. if not, you can make it 1. setcookie ("CartCount", $NewCount, time()+259200); $newcookie="Quantity[1] ItemName[$ItemName] ItemDescription[$ItemDescription] ItemPrice[$ItemPrice] ItemTax[$ItemTax] ItemShipping[$ItemShipping]"; $CookieName="Cookie_$NewCount_Name"; # Even if $NewCount was empty, it should still fill in the cookie name with "Cookie__Name" But it doesn't.. It cuts off before the numeric.. BUT ONLY WHEN USING A VAR! I HATE THIS! setcookie ($CookieName, $newcookie, time()+259200); echo "NEW CART ITEM [$NewCount] <br>$newcookie"; } Expected result: ---------------- In your temporary internet files, you will notice that the COOKIE'S NAME will be cut off before the number, making it impossible to write a number field to a string without SetCookie realizing (I have no idea why, but I can't get it to work..) that it is not something other than a typed string. Can you guys figure out why I get this bug? Is there a fix? Actual result: -------------- Cookie_ Quantity%5B1%5D+ItemName%5Bnnnnnnn%5D+ItemDescription%5BThe+Item+is+Tall%5D+ItemPrice%5B45%5D+ItemTax%5B5%5D+ItemShipping%5B15%5D%BB localhost/ 1024 533338368 29571867 2694675152 29571263 * -- Edit bug report at http://bugs.php.net/?id=24285&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=24285&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=24285&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24285&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24285&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24285&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24285&r=support Expected behavior: http://bugs.php.net/fix.php?id=24285&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24285&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24285&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24285&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24285&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24285&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24285&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24285&r=gnused