I am trying to create a session for my web application using Dancer2. I currently using mysql database. I searched alot of reference on the internet because I'm new to Perl it seem the references are too complicated. Please guide me. Here is my .pm code.
post '/' => sub { my $username = $q->param("username"); my $password = $q->param("password"); my $loginstatement = 'SELECT * FROM account WHERE username=? a +nd password=?'; my $sth = $dbh->prepare($loginstatement) or die $dbh->errstr; $sth->execute(params->{'username'}, params->{'password'}) or d +ie $sth->errstr; my (@userID) = $sth->fetchrow_array; if ($userID[0] != 0 && $userID[11] ==1 ){ my $sessionstatement = "SELECT * FROM sessions"; my $sth2 = $dbh->prepare($sessionstatement) or die $db +h ->errstr; my (@sessID)= $sth2->fetchrow_array; if($userID[3] == $sessID[1]) { session 'logged_in' => true; }
In reply to session with mysql database. by newbie430
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |