save() won't do what you want in this context most probably - but you can create a new CGI object from an existing one so what you probably want to do is rather than use save() you serialize the CGI object (using Data::Dump, Storable, Data::DumpXML or whatever) and then store the serialized data in the database. Then when you want to get it back you can deserialize it into a variable and then pass that to CGI->new(). An example using Storable (omitting the database bit):
#!/usr/bin/perl -w use strict; use CGI; use Storable qw(freeze thaw); my $cgi1 = CGI->new(); # do some stuff my $save_cgi = freeze($cgi1); # # save $save_cgi to a database # time passes and you get it back into $save_cgi # (this is possibly in another process my $restore_cgi1 = thaw($save_cgi); my $cgi2 = CGI->new($restore_cgi1);
You should be extremely cautious when deserializing data from a database and ensure that the permissions do not allow people to put random stuff into the table that could be deserialized in such a way that it could potentially be harmful. Hope that helps
/J\

In reply to Re: CGI.pm saving state to database by gellyfish
in thread CGI.pm saving state to database by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.