diff --git a/client.inc.php b/client.inc.php
index 91956c0d7dfc36e5ffb374f0812cea2f9693c6b9..ce36e7b68d886cb948ac4c9c4cd16555d104df08 100644
--- a/client.inc.php
+++ b/client.inc.php
@@ -50,6 +50,8 @@ if($_SESSION['_client']['userID'] && $_SESSION['_client']['key'])
 //is the user logged in?
 if($thisclient && $thisclient->getId() && $thisclient->isValid()){
      $thisclient->refreshSession();
+} else {
+    $thisclient = null;
 }
 
 /******* CSRF Protectin *************/