I made a few minor adjustments, but it seems OK otherwise.
#!/usr/bin/perl use strict; use warnings; use CGI::Session; sub login { my ($dbh) = @_; my ($email) = $dbh->quote( my $CGI->param('email') || undef ); my ($password) = $dbh->quote( $CGI->param('password') || undef ); my ($loginSessionID) = $CGI->param('loginSessionID') || undef; eval { do { my $tmp = "SELECT\n id\nFROM\n users\nWHERE\n LOWER(email) = LOWER($email)\n AND password = $password\n"; my $sth = &return_query( $dbh, $tmp ); my (@row) = $sth->fetchrow_array; my %result; $result{'userID'} = undef; if (@row) { $result{'userID'} = $row[0]; CGI::Session->name( my $CONFIG->{'userSession'}{'cookies'}{'LOGIN'}{'n +ame'} || 'CGISESSID' ); my $SESSION = CGI::Session->load( 'driver:MySQL', $CGI || $loginSessionID, { DataSource => join( ':', $CONFIG->{'mysql'}{'DSN'}, $CONFIG->{'mysql'}{'Collection'} ), TableName => 'sessions', IdColName => 'id', DataColName => 'data', Handle => $dbh, } ) || die( CGI::Session->errstr ) . "\n"; if ( $SESSION->is_expired ) { $SESSION->delete(); $SESSION->flush(); } if ( $SESSION->is_empty ) { $SESSION = CGI::Session->new(); } $result{loginSessionID} = $SESSION->id(); $SESSION->param( 'userID', $result{'userID'} ); $SESSION->expire( $CONFIG->{'userSession'}{'cookies'}{'LOGIN'}{expir +e} || '+30m' ); my %COOKIES; $COOKIES{'loginSession'} = $CGI->cookie( -name => $CONFIG->{'userSession'}{'cookies'}{'LOGIN'}{'na +me'}, -value => $SESSION->id(), -expires => $CONFIG->{'userSession'}{'cookies'}{'LOGIN'}{'ex +pire'} || "+30m", -path => $CONFIG->{'userSession'}{'cookies'}{'LOGIN'}{'pa +th'} || "/", -domain => $CONFIG->{'userSession'}{'cookies'}{'LOGIN'}{'do +main'} || "", -secure => $CONFIG->{'userSession'}{'cookies'}{'LOGIN'}{'se +cure'} || 0, ); $SESSION->flush(); } }; my %result; if ($@) { push @{ $result{'error'}; }, $@; } return encode_json( \%result ); } }

In reply to Re: CGI::Session not "storing" anything by Khen1950fx
in thread CGI::Session not "storing" anything by seven.reeds

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.