code: def connect(self):
          
          if self.r_session:
              self.session_logout()
  
          if self.admin_party:
              self._use_iam = False
              self.r_session = ClientSession(
                  timeout=self._timeout
              )
          elif self._use_basic_auth:
              self._use_iam = False
              self.r_session = BasicSession(
                  self._user,
                  self._auth_token,
                  self.server_url,
                  timeout=self._timeout
              )
          elif self._use_iam:
              self.r_session = IAMSession(
                  self._auth_token,
                  self.server_url,
                  auto_renew=self._auto_renew,
                  client_id=self._iam_client_id,
                  client_secret=self._iam_client_secret,
                  timeout=self._timeout
              )
          else:
              self.r_session = CookieSession(
                  self._user,
                  self._auth_token,
                  self.server_url,
                  auto_renew=self._auto_renew,
                  timeout=self._timeout
              )
  
          # If a Transport Adapter was supplied add it to the session
          if self.adapter is not None:
              self.r_session.mount(self.server_url, self.adapter)
          if self._client_user_header is not None:
              self.r_session.headers.update(self._client_user_header)
  
          self.session_login()
  
          # Utilize an event hook to append to the response message
          # using :func:`~cloudant.common_util.append_response_error_content`
          self.r_session.hooks['response'].append(append_response_error_content)
docs: Starts up an authentication session for the client using cookie
          authentication if necessary.