use strict; use CGI qw/:standard/; use CGI::Cookie; my $mycookie = new CGI::Cookie(-name=>'user', -value=>'sample_value', -expire=>'+1h', -path=>'/', -domain=>$ENV{HTTP_HOST}); print "Set-Cookie: $mycookie\n"; print "Location: otherfile.cgi\n\n";