8 my $sessionID=$query->cookie('sessionID');
11 open (S, "/tmp/sessions");
12 while (my ($sid, $u, $lasttime) = split(/:/, <S>)) {
15 (next) if ($sid eq $sessionID);
16 $sessions->{$sid}->{'userid'}=$u;
17 $sessions->{$sid}->{'lasttime'}=$lasttime;
19 open (S, ">/tmp/sessions");
20 foreach (keys %$sessions) {
21 my $userid=$sessions->{$_}->{'userid'};
22 my $lasttime=$sessions->{$_}->{'lasttime'};
23 print S "$_:$userid:$lasttime\n";
28 # Check that this is the ip that created the session before deleting it
30 my $sth=$dbh->prepare("select userid,ip from sessions where sessionID=?");
31 $sth->execute($sessionID);
34 ($userid,$ip) = $sth->fetchrow;
35 if ($ip ne $ENV{'REMOTE_ADDR'}) {
36 # attempt to logout from a different ip than cookie was created at
41 $sth=$dbh->prepare("delete from sessions where sessionID=?");
42 $sth->execute($sessionID);
43 open L, ">>/tmp/sessionlog";
44 print L "$userid from $ip logged out at ".localtime(time())." (manual log out).\n";
47 my $cookie=$query->cookie(-name => 'sessionID',
51 print $query->redirect("shelves.pl");
55 print "Logged out of $sessionID<br>\n";
56 print "<a href=shelves.pl>Login</a>";
58 print "Not logged in.<br>\n";
59 print "<a href=shelves.pl>Login</a>";