http://www.perlmonks.org?node_id=84673


in reply to Maintaining state with CGI.pm

CGI.pm offers a good interface for dealing with cookies. You should use those to store information on the users' computers and easily retrieve it for the script. The CGI documentation should tell you how to use those.

Zenon Zabinski | zdog | zdog7@hotmail.com

  • Comment on (zdog) Re: Maintaining state with CGI.pm

Replies are listed 'Best First'.
Re: (zdog) Re: Maintaining state with CGI.pm
by nysus (Parson) on May 31, 2001 at 22:10 UTC
    Is this the best way to handle this? What if cookies are turned off?

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar";
    $nysus = $PM . $MCF;

      Or you can pass the parameters from the previous form to the next form. You can set the parameters by using the param() routine similarly to this:

      $q->param(-name=>'veggie',-value=>'tomato');

      Update: My bad. You can pass the parameters to the next form by using the hidden input method. (See reply.)

      Zenon Zabinski | zdog | zdog7@hotmail.com

        But that just stores the value "tomato" in the current CGI object, it doesn't pass it to the next CGI form. You can pass stuff along with hidden fields. In the first cgi,

          print textfield(-name => "foo");

        In the second one,

          print hidden(-name => "foo");

        CGI automatically remembers the value of "foo" that was submitted by the first form, and uses it on the second one.