ID: 24364 Updated by: [EMAIL PROTECTED] Reported By: webmaster at microwebsolutions dot com -Status: Open +Status: Bogus Bug Type: Session related Operating System: Unix(Zeus/3.4) PHP Version: 4.3.1 New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. .. Previous Comments: ------------------------------------------------------------------------ [2003-06-27 13:19:38] webmaster at microwebsolutions dot com Description: ------------ I am a developing a shopping cart system, and now I am really going to hurt because I have been working on it through windows NT on a PHP 4.3.1 software. I have everything "PERFECT" on my local machine; all my cookies work here, and the whole system is beautiful. I am now uploading the entire site to a UNIX PHP 4.3.1 environment, and now there is one small problem; when I remove an item from my shopping cart, it removes everything, and leaves the CookieCount at the original count. Basically here is what happens: Add 1 item to the cart, Add another. Delete the first 1, both cookies disapear... Is there any idea why this would happen?? the time limit on each cookie is set to 3 weeks. Please help, as I need to finish this project by monday; I am panicing. Reproduce code: --------------- Items come into the cart like so: ItemName, ItemDescription, ItemQuantity, ItemPrice, ItemTax, ItemShipping. I interpret these fields into cookies, readable with a function I made. $seti is the value of the CookieCount; basically if I have 10 items in the shopping cart, $seti would be #1 or #4 or whatever of 10 in the 'for' statement. This reads the HOW TO GET REMOVAL FROM THE FORM: $Removal=""; $Removal=$_REQUEST["Remove_" . $seti . ""]; $NewQuantity=$_REQUEST["Quantity_" . $seti . ""]; if ($Removal=="remove") { # Remove the item from the cart. # Skip it then, so it will be excluded when we delete the entire batch of cookies. setcookie ("Cart_" . $seti . "_Cookie", "", time()+259200); #Timer settings: 60 * 60 * 24 * 3 (3 days) will give you 259200 seconds until the cookies expire, and the shopping Cart is completely cleared out... } ELSE { $newi = $newi + 1; setcookie ("Cart_" . $seti . "_Cookie", "", time()+259200); #Timer settings: 60 * 60 * 24 * 3 (3 days) will give you 259200 seconds until the cookies expire, and the shopping Cart is completely cleared out... $newcookie="Quantity[$NewQuantity] ItemName[$ItemName] ItemDescription[$ItemDescription] ItemPrice[$ItemPrice] ItemTax[$ItemTax] ItemShipping[$ItemShipping]"; setcookie ("Cart_" . $newi . "_Cookie", $newcookie, time()+259200); #Timer settings: 60 * 60 * 24 * 3 (3 days) will give you 259200 seconds until the cookies expire, and the shopping Cart is completely cleared out... } Expected result: ---------------- On my local host, I get exactly what I am supposed to expect; updated quantity and if needed a removal. It works fine on my local host; but now I am on a unix, and it seems that my result is coming WAY unexpectedly bad. I don't know what to do. I noticed when you use cookies, you can't just delete a numbered cookie, you have to re-build the cookies. So as the cookies are being removed, it has to be able to re-align the cookie count; for example: I have 5 items in my cart (5 cookies), and to keep count I have CookieCount. I choose to delete Item #3, so now I will have only 4 Cookies, but I can't just say "Delete #3", because The count would be CookieCount=4, but my cookies would be numbered, 1,2,4,5. Understand? So I have to re-do the cookies as they go along, which is shown in the ELSE section of my code above. Now, when I rebuild the cookies, on the unix machine, it removes all of them, and doesn't update the cookie counter... And the cookie counter is directly after the code above. Actual result: -------------- The actual result is cookies work; ALSO: Add to cart on the unix machine works fine. I can add as many as I want. but when it comes time to remove, EVERYTHING is deleted! This has to be a bug. If it isn't a bug, then this is like saying: When you bring fire into the freezer, the fire turns to ice; ok, so it is a bug, and I need your help. Nathan ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24364&edit=1