10 my $sessionID=$query->cookie('sessionID');
13 if ($ENV{'REMOTE_USER'}) {
14 print $query->header();
16 print startmenu('catalogue');
18 <h1>Logout Feature Not Available</h1>
19 Your Koha server is configured to use a type of authentication called "Basic
20 Authentication" instead of using a cookies-based authentication system. With
21 Basic Authentication, the only way to logout of Koha is by exiting your
24 print endmenu('catalogue');
30 open (S, "/tmp/sessions");
31 # FIXME - Come up with a better logging mechanism
32 while (my ($sid, $u, $lasttime) = split(/:/, <S>)) {
35 (next) if ($sid eq $sessionID);
36 $sessions->{$sid}->{'userid'}=$u;
37 $sessions->{$sid}->{'lasttime'}=$lasttime;
39 open (S, ">/tmp/sessions");
40 foreach (keys %$sessions) {
41 my $userid=$sessions->{$_}->{'userid'};
42 my $lasttime=$sessions->{$_}->{'lasttime'};
43 print S "$_:$userid:$lasttime\n";
46 my $dbh = C4::Context->dbh;
48 # Check that this is the ip that created the session before deleting it
50 my $sth=$dbh->prepare("select userid,ip from sessions where sessionID=?");
51 $sth->execute($sessionID);
54 ($userid,$ip) = $sth->fetchrow;
55 if ($ip ne $ENV{'REMOTE_ADDR'}) {
56 # attempt to logout from a different ip than cookie was created at
61 my $sth=$dbh->prepare("delete from sessions where sessionID=?");
62 $sth->execute($sessionID);
63 open L, ">>/tmp/sessionlog";
64 my $time=localtime(time());
65 printf L "%20s from %16s logged out at %30s (manual log out).\n", $userid, $ip, $time;
68 my $cookie=$query->cookie(-name => 'sessionID',
72 # Should redirect to opac home page after logging out
74 print $query->redirect("/cgi-bin/koha/opac-main.pl");
78 print "Logged out of $sessionID<br>\n";
79 print "<a href=shelves.pl>Login</a>";
81 print "Not logged in.<br>\n";
82 print "<a href=shelves.pl>Login</a>";