public function auth() { //Get the client for transient $client = get_transient('goToTrainingClient'); //Check if transient exists if (false === $client) { //If not - create new client and store it $client = new \Citrix\Authentication\Direct($this->getApiKey()); $client->auth($this->getUsername(), $this->getPassword()); if ($client->hasErrors()) { throw new \Exception($client->getError()); } set_transient('goToTrainingClient', $client, DAY_IN_SECONDS); } return $client; }