diff --git a/html/Elements/SetupSessionCookie b/html/Elements/SetupSessionCookie
index 019dc28..3f8ea84 100755
--- a/html/Elements/SetupSessionCookie
+++ b/html/Elements/SetupSessionCookie
@@ -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.";
         }

