#!/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 ); #### #!/usr/bin/perl use strict; use warnings; use CGI; # Define the session object however you were before, # I can't emulate it as you didn't say what # class was being used use Something; my $session = Something->new(); # Get the header that the session object wants to output my $session_header = $session->header(); # Filter out everything other than Set-Cookie headers $session_header = join("\n", grep /^Set-Cookie/, split("\n", $session_header)); #output the Set-Cookie headers if ($session_header) { print $session_header . "\n"; } #output the headers that CGI generates my $cgi = CGI->new; print $cgi->redirect('http://perlmonks.com');