To create a cookie with the value = cart_id, use the cookie library from Matt Wright (cookie.lib) available at: http://www.worldwidemart.com/scripts/ In the main script (web_store.cgi) insert the following code after: "&read_and_parse_form_data;" ----------- require "cookie.lib"; # If there is a cookie and no present # cart_id, the user has left the system # and returned, so use the previous value if (($form_data{'cart_id'} eq "") && ($ENV{'HTTP_COOKIE'} ne "")) { &GetCookies; @pairs = $ENV{'HTTP_COOKIE'}; foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $cart_id = $value; } } # If there is no cookie and no present # cart_id, the user needs a cart_id and # a matching cookie set elsif (($form_data{'cart_id'} eq "") && ($ENV{'HTTP_COOKIE'} eq "")){ &delete_old_carts; &assign_a_unique_shopping_cart_id; } # If there is a present cart_id, use it. # The user has not left the system else { $cart_id = $form_data{'cart_id'}; } ------------ be sure that all this happens before your content header, i.e. before the line that reads: print "Content-type: text/html\n\n"; Finally, within the subroutine "assign_a_unique_shopping_cart_id," add the following code as the very last step: ------- $cookie{'cart_id'} = $cart_id; &SetCookies('cart_id',"$cart_id"); ------ 'This code should be placed right before the final "}" at the end of the subroutine. What you get with all this is a cookie that survives until the browser session ends. It's a good one if you just want people to be able to wander outside the web store while they're shopping. If you want a persistent cookie with an expiration date, you'll need to adapt this code according to the instructions in cookie.lib