#!/usr/bin/perl #################################### use CGI qw/:standard/; use CGI::Cookie; sub write_cookie { my $c = new CGI::Cookie(-name => 'foo', -value => ['bar','baz'], -expires => '+3M' ); print header(-cookie=>[$c]); %cookies = fetch CGI::Cookie; ## This is very bad. You should check that $cookies{'ID'} exists ## or your script will die when you run this code. # $id = $cookies{'ID'}->value; ## You've already filled %cookies with the cookies. Why ## do it again? # %cookies = parse CGI::Cookie($ENV{COOKIE}); } 1; #### #!/usr/bin/perl require "common.cgi"; write_cookie(); print "Something";