#!/usr/bin/perl use strict; use warnings; use CGI; my $cgi = CGI->new; my $cookie = $cgi->cookie(-name => 'test', -value => 'testval', -expires => "+2h"); print $cgi->redirect( -location => 'http://perlmonks.com', -cookie => $cookie );