diff --git a/lib/user.php b/lib/user.php
index f1903093d6d914887c9b4db3f796ffdf6f05c4f4..23b88aa1d061281906920519b64d900b6e30b369 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;
 	}
 
 	/**