diff --git a/lib/user.php b/lib/user.php
index 37e6dcd1435366b8c31efa0860894acf1845f924..24435eab23c8533bb7d2e93ef7f163ba364b0508 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -240,13 +240,17 @@ class OC_User {
 	 * Checks if the user is logged in
 	 */
 	public static function isLoggedIn(){
+		static $is_login_checked = null;
+		if (!is_null($is_login_checked)) {
+			return $is_login_checked;
+		}
 		if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) {
 			OC_App::loadApps(array('authentication'));
 			if (self::userExists($_SESSION['user_id']) ){
-				return true;
+				return $is_login_checked = true;
 			}
 		}
-		return false;
+		return $is_login_checked = false;
 	}
 
 	/**