Did you know that this is exactly what the Apache::Session module does? All you have to do is store the key on the client side. Don't be put off by the name: it has nothing to do with Apache or mod_perl.

To your specific questions, this is a good way to do it but don't put much data in the serialized object or it will start to get slow. You should only put things like keys into other tables in there (shopping cart ID, user ID). You don't need to get Storable to read from the database. You just give it a scalar containing serialized data that you fetched from the database. Storable is available from ActiveState's PPM system and I think they ship it with their distribution. There are other pre-built Perl distros for Win32 that have it, like the one Randy Kobes builds. Storable will be part of the standard library starting in perl 5.8.


In reply to Re: Maintaining state through storable.pm? by perrin
in thread Maintaining state through storable.pm? by BUU

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.