#I've not posted use directives, HTML::Template variables declarations and et ceterea, because it doesn't actually matter in this case.
if (!$cookie{CGISESSID}{value}[0]) { #checkif there is a session cookie in user's browser.
print "Content-Type: text/html\n\n";
print $auth->output; # render form which would require enter login and password.
} else {
# render secret page