From: webmaster at microwebsolutions dot com
Operating system: Unix(Zeus/3.4)
PHP version: 4.3.1
PHP Bug Type: Session related
Bug description: Delete one cookie, they all get deleted...???
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 bug report at http://bugs.php.net/?id=24364&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=24364&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=24364&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=24364&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=24364&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=24364&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=24364&r=support
Expected behavior: http://bugs.php.net/fix.php?id=24364&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=24364&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=24364&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=24364&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24364&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=24364&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=24364&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=24364&r=gnused