I upveoted you because I agree that a good way to learn is to tinker with stuff. However, you certainly shouldn't clutter CPAN with duplicate modules. Perhaps the best thing to do is start with the appropriate CPAN module and make it do what you want then release the changes back to the author so that they can be incorporated into the next version. Hopefully that way you learn the guts & theory, think of some stuff that you never realized about the problem before and everyone benefits since another set of eyeballs have looked at the code and another brain has thought about it. The end result should be a more powerful, more general, more reliable piece of software.

BTW session management is tricky. The Apache::Session modules is very cool because it has different pluggable lock and storage modules. Getting storage correct is non-trivial since you need to decide what semantics your sessions should have. Things to think about are how you want your session to behave when two requests happen simutaneously. Will the change that happens second blow away the first even if the first has not yet written the state? Will the second page block until the first change happens? If you decide that you do not need blocking did you remember at least to lock the session object when it is being read and written so that changes mid-read or write do not corrupt the session.

You can choose not to think about this and your code will work most of the time, but when the load gets high and pages start holding the sessions open for a while you will start getting weird errors that are very hard to track down. The Apache::Session code has a Transaction argument you can pass to lock the session from when it is read from disk until it is closed. It also locks the object when it is being changed (even if you are not in transactional mode).

-ben


In reply to (Knob)Re: Re: How to code the session page by knobunc
in thread How to code the session page by Draff

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.