Thank you for your help, I've used your code and got pretty far with it, I believe, but I've run into a problem or two. I don't know if the cookie is getting set or not, but it says I'm logged in if I type in the correct password.
I have url_params that run off this script, but when I'm supposively logged in and I go to a url_param, it errors out saying I have the wrong password. Can you see a problem below with the cookie being sent? And if I reload the page after I log in, I stay logged in. But if I go back to the url using the location bar, it tells me to relog back in.
Thank you!
my $adminpassword = "test";
my %cookie;
if ( !exists $cookie{'pass'} ) {
if ( param() ) {
my $adminpass = param('admin');
if ( $adminpass eq $adminpassword ) {
my $cookiename = cookie(
-name => 'cookie',
-value => 'loggedin',
-expires => '+1h'
);
print header, start_html();
# print rest of page here
print "you are logged in";
}
}
else {
print header, start_html();
print "Incorrect password, please click back and try again
+";
exit;
}
}
else {
print header, start_html();
print start_form(),
table(
Tr(
td("Admin Password: "),
td(
textfield(
-name => 'admin',
-size => 10
)
)
),
Tr( td(), td(submit) ),
),
end_form(), hr();
}
}