my %cookie = CGI::Cookie->fetch; #### if (exists $cookie{test}) { # we have our cookie, do something with $cookie{test}->value } else { # we don't have a cookie, need to make one my $cookie = CGI::Cookie->new(-name=>'test',-value=>12345); # now we "inject" into the HTTP headers print header(-cookie=>$cookie); }