Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Using CGI: set cookie and redirect

by rpike (Scribe)
on Feb 12, 2010 at 19:45 UTC ( [id://822920]=perlquestion: print w/replies, xml ) Need Help??

rpike has asked for the wisdom of the Perl Monks concerning the following question:

How can I use the CGI module to set a cookie AND redirect immediately after it? What's the easiest way to accomplish this while using this particular module? Thanks in advance for any help.

Replies are listed 'Best First'.
Re: Using CGI: set cookie and redirect
by zwon (Abbot) on Feb 12, 2010 at 20:45 UTC

    You can pass -cookie parameter to redirect method:

    use strict; use warnings; use CGI qw(:standard); my $cookie = cookie( -name => 'test', -value => 'tset' ); print redirect( -uri => '/', -cookie => $cookie );
Re: Using CGI: set cookie and redirect
by ww (Archbishop) on Feb 12, 2010 at 22:38 UTC

    This is a classic case for "what did you try?" ...and since you've been a Monk for some 5 years, you may even have heard that before. In fact, this is one of two posts today by you demonstrating a serious lack of effort. - -

    And what did you search to learn the answer?

    Obvious candidates (in no particular order):

    1. Super Search
    2. Tutorials
    3. perldoc CGI
      ...and, of course,
    4. big G (with 119k results for that search)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-23 22:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found