Do you see a reason why this would not work?

Without seeing what's going on down in CWT::Site_DB, it's hard to say.

A flag goes up when I see code that mixes direct queries with queries that are abstracted away behind classes. It's hard to get a grip on what your connections and statement handles are up to unless they're either all exposed, or all abstracted away behind well unit-tested classes (or at least that's been my experience).

Scanning the code, it shows that you're starting off with an id, querying first to get the corresponding username, then querying and iterating over a session table to look for (a non-expired session?) with the same username

Is that something you could arrange to do in a single query, using JOINs or OUTER JOINs?

Also, it's generally bad form to "SELECT *" in production code unless you're going to use all of the fields. Better to name the field explicitly.


In reply to Re: Sessions, Perl and MySQL by dws
in thread Sessions, Perl and MySQL by powerhouse

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.