in reply to Redirects and CGI.pm

However, after I use CGI.pm to set a cookie, it no longer works and just prints it to the web browser as part of the page.

Show us your code. Strip it down to a small example that demonstrates the problem.

Replies are listed 'Best First'.
Re: Re: Redirects and CGI.pm
by Anonymous Monk on Oct 02, 2002 at 19:17 UTC
    my $query = CGI::new(); my $cookie_name = $query->cookie(-name => 'MYHASH', -value => \%hash); print $query->header(-cookie=>$cookie_name); print query->redirect('http://somewhere.else/in/movie/land');
    code. The second answer, stating that redirect & header are basicallyt he same is what i needed. Thank you.
      Therein lies your problem. A redirect is part of the HTTP header; once you print the header (via the header() method) you can't print another one. Try:

      print $query->header(-cookie => $cookie_name, -location => 'http://www.somewhere-else.com/');