# Cookie Login $config{'max_session_hours'} = 4; # Max session time before user must login again. $config{'crypt_salt'} = 'EJ'; # You should make this 2 char salt unique. local %form = &get_form_data unless %form; use vars qw/%cookie $loginalias $loginpassword/; my $cookieName = 'SessionCookie'; foreach my $rel(split /; /, $ENV{HTTP_COOKIE}){ next unless $rel=~s/^\Q$cookieName//; my($bufName, $bufVal) = split(/=/, $rel); $bufVal =~ s/%([a-fA-F0-9]{2})/pack("H2",$1)/eg; $cookie{$bufName} = $bufVal; } my %LOGIN; dbmopen(%LOGIN, 'Session_keys', 0644) or &oops('Cannot open login DBM keys.'); foreach(%LOGIN) { delete $LOGIN{$_} unless ($_ + $config{'max_session_hours'} * 3600 > time); } if($config{'regdir'} ne ''){ $form{loginalias} = ucfirst lc $form{loginalias}; my ($password, $undef) = &read_reg_file($form{loginalias}); if (lc $form{loginpassword} eq lc $password) { ($loginalias, $loginpassword) = setlogin(); } else { print "Location: $ENV{'SCRIPT_NAME'}\?action=reg\n\n"; } } untie(%LOGIN); if ($form{'LOGOUT'}) { foreach(%LOGIN) { delete ($LOGIN{$_}); } print "Location: $ENV{'SCRIPT_NAME'}?action=logout\n\n"; } # End Cookie Login #-######################################## # Print The Page Header # print "Content-type: text/html\n\n"; print $config{'header'};