diff --git a/html/Elements/SetupSessionCookie b/html/Elements/SetupSessionCookie
index b2b6d96..056524e 100755
--- a/html/Elements/SetupSessionCookie
+++ b/html/Elements/SetupSessionCookie
@@ -67,8 +67,7 @@ unless ( $RT::Handle->dbh && $RT::Handle->dbh->ping ) {
}
eval {
tie %session, $session_class,
- $SessionCookie
- || ( $cookies{$cookiename} ? $cookies{$cookiename}->value() : undef ),
+ ( $cookies{$cookiename} ? $cookies{$cookiename}->value() : undef ),
$backends{$RT::DatabaseType}
? {
Handle => $RT::Handle->dbh,
@@ -95,6 +94,21 @@ if ($@) {
undef $cookies{$cookiename};
};
}
+elsif ( !($session{'CurrentUser'} && $session{'CurrentUser'}->id) ) {
+ eval {
+ undef $cookies{$cookiename};
+ 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,
+ };
+ }
+}
if ($@) {
die loc("RT couldn't store your session.") . "\n"