Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Need to set a cookie and a redirect in CGI.pm

by wind (Priest)
on Jun 07, 2011 at 21:31 UTC ( #908570=note: print w/replies, xml ) Need Help??


in reply to Need to set a cookie and a redirect in CGI.pm

The redirect method works by creating a header, so the second call to header is treated as the main body of the returned page.

To fix you simply need to include the cookie in the header created by the redirect method as demonstrated in the resource Your Mother linked to:

use CGI; use strict; use warnings; my $q = CGI->new; my $cookie = $q->cookie( -name=>'lizzy', -value=>'Lizzy', -expires=>'+12h', ); print $q->redirect( -uri => 'http://perl.about.com/', -cookie => $cookie, );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://908570]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-08-08 16:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?