I am a Perl newbie, and i’m stuck with ths problem:
I have a _login.cgi script who manages the login and redirects to the index.cgi page when credentials are correct:
if (functions::check_credentials($input{"username"}, $input{"password"}) eq true ){
$session = new CGI::Session("driver:File", undef, {File::Spec->tmpdir});
$session->param("name", "Carcarlo Pravettoni");
$cookie = $page->cookie(CGISESSID => $session->id);
print $page->redirect( -URL => "index.cgi" -cookie=>$cookie);
} else {...}
but when I try it with correct credentials, i get an infinite redirect loop to _login.cgi (this script itself).
Instead, if I don’t send the cookie with the redirect, all works:
if (functions::check_credentials($input{"username"}, $input{"password"}) eq true ){
$session = new CGI::Session("driver:File", undef, {File::Spec->tmpdir});
$session->param("name", "Carcarlo Pravettoni");
$cookie = $page->cookie(CGISESSID => $session->id);
print $page->redirect( -URL => "index.cgi");
} else {...}
You have a typo here (missing comma after
"index.cgi"):I would suggest that you enable
strictandwarnings(and possiblydiagnostics), and refactor the code till there is no errors/warnings.