diff --git a/html/Elements/SetupSessionCookie b/html/Elements/SetupSessionCookie
index 26eba3b..303827a 100755
--- a/html/Elements/SetupSessionCookie
+++ b/html/Elements/SetupSessionCookie
@@ -33,7 +33,7 @@ my $pm = "$session_class.pm"; $pm =~ s|::|/|g; require $pm;
eval {
tie %session, $session_class,
- $SessionCookie || ( $cookies{'RT_SID'} ? $cookies{'RT_SID'}->value() : undef ),
+ ( $cookies{'RT_SID'} ? $cookies{'RT_SID'}->value() : undef ),
$backends{$RT::DatabaseType} ? {
Handle => $RT::Handle->dbh,
LockHandle => $RT::Handle->dbh,
@@ -42,7 +42,7 @@ my $pm = "$session_class.pm"; $pm =~ s|::|/|g; require $pm;
LockDirectory => $RT::MasonSessionDir,
};
};
- if ($@) {
+ if ( $@ || !($session{'CurrentUser'} && $session{'CurrentUser'}->id) ) {
# If the session is invalid, create a new session.
if ( $@ =~ /Object does not/i ) {
@@ -56,6 +56,18 @@ my $pm = "$session_class.pm"; $pm =~ s|::|/|g; require $pm;
};
undef $cookies{'RT_SID'};
}
+ elsif ( !($session{'CurrentUser'} && $session{'CurrentUser'}->id) ) {
+ tied(%session)->delete;
+ tie %session, $session_class, undef,
+ $backends{$RT::DatabaseType} ? {
+ Handle => $RT::Handle->dbh,
+ LockHandle => $RT::Handle->dbh,
+ } : {
+ Directory => $RT::MasonSessionDir,
+ LockDirectory => $RT::MasonSessionDir,
+ };
+ undef $cookies{'RT_SID'};
+ }
else {
die "RT Couldn't write to session directory '$RT::MasonSessionDir': $@. Check that this dir ectory's permissions are correct.";
}