Click to See Complete Forum and Search --> : Cant read cookies


tdavis
08-31-2006, 06:47 AM
I have a problem reading this one cookie. I am storing shopping cart items already formatted as a string to Paypal. I have another one that stores the number of items added. The number of items writes and reads OK (I can display it using Perl). But, although the shopping cart string cookie writes OK (I can see it using windows explorer) it will not read. The perl script I wrote to display it shows only the first variable part.

Does the equal sign and/or the ampersand mess up the display when I read the cookie value in? I have tried everything!

Here is the code:

require 'cookie.pl';

# Get orders cookie to see if any items are already in the shopping cart.
if (&GetCookies('orders')) {
$itemcount=$Cookies{'orders'};
}

if (&GetCookies('cart1')) {
$test=$Cookies{'cart1'};
}


print "Content-type: text/html\n\n";
print "<br>Number of orders: $itemcount<br>";
print "<br>test: $test<br>";

for ($count=1; $count<$itemcount+1; $count++) {
$cart = "cart" . $count;
if (&GetCookies($cart)) {
$items=$Cookies{$cart};
$itemstring = $items;
print "<br>Order $count: $itemstring<br><br>";
}}

Here is part of the cookie:
(orders displays the 15 OK, but cart displays only &item_name_1)....

orders
15
www.tdavisconsulting.com/lifetoimage/
1024
1158030336
30859009
2713785904
29805801
*
cart1
&item_name_1=11x14%20Print%20(Luster)&item_number_1=008&amount_1=35.00&quantity_1=1&on0_1=Leigha0312.jpg
www.tdavisconsulting.com/lifetoimage/
1024
1158030336
30859009
3321701472
29805718
*

Thanks-
tdavis

tdavis
08-31-2006, 04:49 PM
My mistake is to use an ampersand and an equal sign in the cookie value. I changed those characters to a %26 for the ampersand, and a %3D for the equal sign, and now everything is good.