From my main script, I created a new CGI::Session object to start a new session and used MySQL for persistent data storage. It worked.

I keep on pushing data to the session for use later on. When the user logs-in, I store the user credentials to the session. However, I have a need to identify a session with the user so I added a column in the "sessions" table named user_id (INT(10) UNSIGNED NOT NULL).

After the user log-on credentials were verified and authenticated, it's time for me to update the sessions table to add the user_id and associate it with a session. Here's the simple code:

$sth = $dbh->do ("UPDATE sessions SET user_id='$user_id' WHERE id LIKE '$CGISESSID'");

The problem here is that when I viewed the session table, the user_id column has not been updated. I verified the variables: $user_id and $CGISESSID indeed have real values. I just can't understand why it never got updated... is there something wrong with the above SQL code? To experiment further, I tried this (instead of the above code):

$sth = $dbh->do ("DELETE FROM sessions");

To my amazement, the session that was created was still there, while the old ones were deleted. Isn't it supposed to be delete also?

I have an impression that this is a simple problem, but it got tricky that I proved myself wrong. Any ideas are welcomed.

Thanks, Jay Soon

In reply to Updating a new column entry for CGI::Session 'sessions' table by soon_j

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.