I won't answer your question as such, but will give you an alternative instead.

If part of your aim is a learning exercise, why not handle the sessions yourself? In the web applications that I write, I am generally only interested in keeping track of people who are logged (or logging) into a particular system. To do this, I set some cookies:

Only the first of these is needed to maintain state - everything hangs off the user ID. So, when the user logs in, these cookies get set. Every time a page is loaded, one of the first things to happen is to read in the cookies from the HTTP request; once we've got the user ID cookie, we can then look up any state information that we might have saved in the database. (We could also save that state information directly in cookies; I tend not to do this because I don't want people altering cookies to fool my system.)

Here's a slightly modified and cut-down version of how I read in cookies (%cookies is declared elsewhere):

sub pop_cookies { my $rawcookies=$ENV{HTTP_COOKIE}; $rawcookies=~s/Cookie:|\s//ig; for my $nvp (split(/;/,$page{rawcookies})) { my ($n,$v)=split(/=/,$nvp); { $cookies{$n}=$v; } } }

I really think that if you build this yourself, you will understand how and why state preservation can/does work - and you will code a better application as a result. Modules are great but if, when you build your house, you also learn how to make bricks - you will gain that much more insight and experience.

Hope this helps!


In reply to Re: session management by smiffy
in thread session management 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.