First suggestion: try using something like CGI::Persistent (admittedly not my favorite... I'm rolling my own CGI::Session for a project which does things very differently). There's a whole bunch of other persistent storage modules around, I think there's even a mailing list called <acronym>POOP</acronym> (Perl Object Oriented Persistence).

Why use these? They keep track of individual sessions (what if multiple people go to your web page at the same time?) and the associated file management etc.

As to your specific example: does the web user have permissions to modify the file? (I suggest you do not save session data in the same folder as your web scripts, which is what your example looks like it's doing ... you're asking for trouble securitywise if you do.)

You're also not locking the file. That could get you into trouble if somebody else tries to access the process (hey? what if the user doesn't like the speed of the page and hits reload? Imagine two processes from the same script are accessing the file, even if only one user is using the script).


In reply to Re: Keeping form information in CGI by rrwo
in thread Keeping form information in CGI by deryni

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.