I know that the limit is 20 cookies per domain, but what exactly is a "cookie"? I have four cookies total and three of them are arrays. Is each value in the array considered a cookie? Because when I reach a total of 20 values, and then add another, some start to get deleted.
I created a shopping cart using cookies because I wanted to not use the server as much as possible. Each product that I add, requires a value in 3 different cookies: ID (cart_prodid), Quantity (cart_prodqty), and Any Options (cart_prodoption). There is also another cookie for the last item added (cart_lastadded), but this is not an array like the others.
Here is my code:
$t = time()+3600247;
setcookie("cart_prodid[$cartid]", "$cartid", $t, "/new/site/", ".mydomain.com");
setcookie("cart_prodqty[$cartid]", "$qty_new", $t, "/new/site/", ".mydomain.com");
setcookie("cart_prodoption[$cartid]", "$cartoption", $t, "/new/site/", ".mydomain.com");
setcookie("cart_lastadded", "$cartprodtitle", $t, "/new/site/", ".mydomain.com");
I cut and pasted the phpinfo(); right before the next product would be added and start to erase the cookies. Is this a bad way to do a shopping cart?
_COOKIE["cart_prodid"] Array
(
[TS17S] => TS17S
[TS17M] => TS17M
[TS17L] => TS17L
[TS17X] => TS17X
[TS17Y] => TS17Y
[TS17Z] => TS17Z
)
_COOKIE["cart_prodqty"] Array
(
[TS17S] => 1
[TS17M] => 1
[TS17L] => 1
[TS17X] => 1
[TS17Y] => 1
[TS17Z] => 1
)
_COOKIE["cart_prodoption"] Array
(
[TS17S] => 0
[TS17M] => 1
[TS17L] => 1
[TS17X] => 1
[TS17Y] => 1
[TS17Z] => 1
)
_COOKIE["cart_lastadded"] T-shirt