+ my $dbh = $s->_dbopen();
+ my ($nusername, $nlast) =
+ $dbh->selectrow_array("SELECT username, last".
+ " FROM $s->{S}{assocdb_table}".
+ " WHERE associd = ?", {}, $qassoc);
+ return undef unless defined $nusername;
+ my $timeout = $s->{S}{login_timeout};
+ return undef unless !defined $timeout || time <= $nlast + $timeout;
+
+ return ($nusername, $qassoc);
+}
+
+sub check ($) {
+ my ($s) = @_;
+
+ my ($nusername, $qassoc) = $s->_check() or return undef;
+
+ # hooray
+ $dbh->do("UPDATE $s->{S}{assocdb_table}".
+ " SET last = ?".
+ " WHERE associd = ?", {}, time, $qassoc);
+ $dbh->do("COMMIT");
+
+ $username = $nusername;
+ $assoc = $qassoc;
+ return $username;
+}
+
+sub logout ($) {
+ my ($s) = @_;
+
+ if (my ($nusername, $qassoc) = $s->_check()) {
+ $dbh->do("DELETE FROM $s->{S}{assocdb_table}".
+ " WHERE associd = ?", {}, $qassoc);
+ $dbh->do("COMMIT");
+ }
+}