Perl CGI::Cookie not setting in Safari -


i'm new perl. have made simple login script supposed set cookie before redirecting form page. have tried can think of cookie not set in safari. several posts show slight variations , i've tried them all.

my code:

my $userquery = "select user_name , password egi_users user_name = '$username' , password = '$cryptword'"; $result = $dbh->prepare($userquery); $result->execute()or die "mysql error : $dbi::errstr\n";  $rows = $result->rows;  if($rows == 1){      #login valid. create cookie , send patient_data page.                                                                                               #print("success\n");                                                                                                                                         $c = cgi::cookie->new(-name=>'login_access',                              -value=>$username,                              -expires=>'+1h');      print $q->redirect(-uri=>'http://mytestserver.com/cgi/patient_data.pl' , -status => '301' , -cookie => $c);   }else{      print $q->redirect(-uri=>'http://mytestserver.com/); } 

i've implemented of seems necessary fro cgi;

use cgi; use cgi::carp... use cg::session; use cgi::cookie;

the script correctly validates , redirects no cookie ever set. i'm not sure i'm doing. if have better suggestion in approach, great too.

thanks looking

status 301 permanent redirect. you're checking see if user logged in or not, , give them permanent redirect if give correct username/password? how log out or log in else? impossible.

you need clear safari cache , use status 303, 'see other', this.

also, code vulnerable sql injection attack. try:

my $userquery = "select user_name , password egi_users user_name = ? , password = ?"; $result = $dbh->prepare($userquery); $result->execute($username, $cryptword)or die "mysql error : $dbi::errstr\n"; 

also, seem log app making cookie username in it. needs passwords...


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -