     /**
      *  Logs out any authenticated user and clears out any associated cookies
      */
-    @objc public func logout(completion: @escaping () -> Void = {}){
+    @objc(logoutAndResetLocalUserLoginSettings:completion:)
+    public func logout(resetLocalUserLoginSettings: Bool = true, completion: @escaping () -> Void = {}) {
+        let resetIfNeeded = {
+            if resetLocalUserLoginSettings {
+                DDLogDebug("Deleted login tokens and other browser cookies")
+                self.resetLocalUserLoginSettings()
+            }
+        }
+        let failure: (Error) -> Void = { error in
+            DDLogDebug("Failed to log out: \(error)")
+            resetIfNeeded()
+            completion()
+        }
+        guard let loginSiteURL = LoginURL.wikipedia else {
+            failure(LoginURLError.couldNotConstructLoginURL)
+            return
+        }
         logoutManager = AFHTTPSessionManager(baseURL: loginSiteURL)
         _ = logoutManager?.wmf_apiPOST(with: ["action": "logout", "format": "json"], success: { (_, response) in
-            DDLogDebug("Successfully logged out, deleted login tokens and other browser cookies")
+            DDLogDebug("Successfully logged out")
             // It's best to call "action=logout" API *before* clearing local login settings...
-            self.resetLocalUserLoginSettings()
+            resetIfNeeded()
             completion()
         }, failure: { (_, error) in
             // ...but if "action=logout" fails we *still* want to clear local login settings, which still effectively logs the user out.
-            DDLogDebug("Failed to log out, delete login tokens and other browser cookies: \(error)")
-            self.resetLocalUserLoginSettings()
-            completion()
+            failure(error)
         })
     }
     

    }

}

    }
    
    public func isUserLoggedInRemotely() -> Bool {
        guard let loginSiteURL = LoginURL.wikipedia else {
            return false
        }
        let taskGroup = WMFTaskGroup()
        let sessionManager = AFHTTPSessionManager(baseURL: loginSiteURL)
        var errorCode: String? = nil
