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)