in reply to CGI::Session not "storing" anything

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 ); } }