Apache2/ModPerl2/Mason stack. I have successfully written my first cookies! Problem is, when I try to use the %session hash in code, it doesn't seem to update. I'm tying the hash thusly:
    tie %HTML::Mason::Commands::session, 'Apache::Session::MySQL',
    ($cookies{$cookie_name} ? $cookies{$cookie_name}->value() : undef),
    {
         Handle => $dbh,
         LockHandle => $dbh
    }
    ;
And I'm trying to modify the contained info thusly:
   $sth = $dbh->prepare($sql) || die qq{Error preparing "$sql": $DBI::errstr};

   $result = $sth->execute($username, $password) || die qq{Error preparing "$sql": $DBI::errstr};

   # Get the user ID
   ($user_id) = $sth->fetchrow_array;

   # Set the user ID for this session
   $HTML::Mason::Commands::session{user_id} = $user_id;
But when I print out the guts of the session, I get no userid field.
   foreach my $key (keys %HTML::Mason::Commands::session) {
      print "key: $key<br/>value: $HTML::Mason::Commands::session{$key}<br/><br/>";
   }
...
   key: _session_id
   value: e3dc89199f3d9133dcae0fab8b68df8d
I'm new to cookies and sessions, so I'm not sure where to look, but what I've read said the %session hash should update the table automagically since it's tied a la Apache::Session::MySQL. Doesn't seem to be happening though. Help?

In reply to Apache::Session:MySql tied hash not updating db table by wolfie7873

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.