CGI is a stateless environment. If you wish to maintain state across CGI requests, you'll need two things: Somewhere to store session data, and some way to securely identify which session belongs to who.

CGI::Session can help with this. I prefer working with the Mojolicious web framework, though, which makes session handling pretty simple.

I know it's terribly outdated, but CGI Programming with Perl (O'Reilly) does help to explain the nuts and bolts that one isn't fully exposed to when using a more modern framework. Pick up a used copy (one penny, plus shipping on Amazon, for example). 2nd edition is better than 1st, but both are over a decade old. Nevertheless, understanding the mechanics is still relevant even if you're moving beyond bare CGI into modern frameworks sitting on top of Plack.

Update: With respect to Mojolicious, be sure to take the advice of the tutorials by starting with a Mojolicious::Lite app. Most of the time that's adequate. You can start with the templates embedded directly in the app, and later explode them out to their own separate files. In my experience you don't really need a full Mojolicious app (with router and controllers separated) until the application grows large.


Dave


In reply to Re: One script, multiple html forms? by davido
in thread One script, multiple html forms? by entropyal

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.