in reply to Removing dot before cookie host/domain URL

You are on the right track. Let's give the page a name MyTestCookie.cgi
Delete the -domain=>'foobar.com', so your code looks like this:
#!/usr/bin/perl use CGI; $query = new CGI; $cookie1 = $query->cookie( -name=>'TheCookie', -value=>'anything ', -expires=>'+24h', -path=>'/', -secure=> 0); print $query->header(-cookie=>$cookie1); print"<html> <body> Done. </body> </html>"; print $query->end_html
Then load the page (and cookie) without the 'www' in the URL:
http://foobar.com/MyTestCookie.cgi

That should do it!