in reply to Re^2: Setting Cookies First and Redirecting Page
in thread Setting Cookies First and Redirecting Page
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.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Setting Cookies First and Redirecting Page
by Anonymous Monk on Sep 15, 2006 at 19:14 UTC | |
by derby (Abbot) on Sep 15, 2006 at 20:09 UTC | |
by ptum (Priest) on Sep 15, 2006 at 19:52 UTC |