Since there is restriction of twenty cookies per server, we might not want to use too many cookies.
But I have been searched and asked forum and read the books. only the following information I found.
According to the "professional php programming" p.466
"Fortunately, we can store multiple values in a single cookie. To do this, we simply treate the cookie as an array, and assign a value to each element in that array."
BUT THIS STATEMENT IS WRONG. (or I misunderstood it???)
If we simply treate the cookie as an array, EACH ELEMENT WILL BE CONSIDERED AS ONE COOKIE. This will not solve the problem of the restriction of twenty cookies per server.
I have used the approach "professional php programming" suggest
for ($index=0; $index<40; $index++)
{
setcookie("mycookiearray[$index]", $index);
}
They are considered 40 cookies NOT ONE COOKIE, and only the last 20 will be saved in the cookie value.
I have three quesions:
First, is the statement of "professional php programming" p.466
wrong? So many people must have used that book. Or in the new edition of that book it has been corrected?
Second, then how to handle multiple value cookies, this is popular used in the shopping cart, how all these shopping cart handle the multiple value cookes and 20 cookie per server issue?
Once again, "professional php programming" shopping cart example uses array. BUT IF WE ADD TOO MANY PRODUCTS INTO HTE SHOPPING CART, it will be over 20 cookie limit. It will break the shopping process.
Third, so how to handle multiple value cookie like shopping cart, use serialize is the only approach?
Fourth, any other solutions about the 20 cookie per server restriction for the multiple value cooke and shopping cart appliaction? How the other shopping cart application works?
Thanks!