Looking at the code of redirect() in CGI.pm, it looks to me as though the redirect() header can take a $cookie as an argument:
sub redirect { my($self,@p) = self_or_default(@_); my($url,$target,$status,$cookie,$nph,@other) = rearrange([[LOCATION,URI,URL],TARGET,STATUS,['COOKIE','COOKIE +S'],NPH],@p); $status = '302 Found' unless defined $status; $url ||= $self->self_url; my(@o); foreach (@other) { tr/\"//d; push(@o,split("=",$_,2)); } unshift(@o, '-Status' => $status, '-Location'=> $url, '-nph' => $nph); unshift(@o,'-Target'=>$target) if $target; unshift(@o,'-Type'=>''); my @unescaped; unshift(@unescaped,'-Cookie'=>$cookie) if $cookie; return $self->header((map {$self->unescapeHTML($_)} @o),@unescaped +); }
Why not build your cookie, and then pass it to the redirect() header just as you did for the 'normal' header? (I haven't tried this.)
In reply to Re^3: Setting Cookies First and Redirecting Page
by ptum
in thread Setting Cookies First and Redirecting Page
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |