CAS_Client::logout PHP Method

logout() public method

This method is used to logout from CAS.
public logout ( array $params ) : void
$params array an array that contains the optional url and service parameters that will be passed to the CAS server
return void
    public function logout($params)
    {
        phpCAS::traceBegin();
        $cas_url = $this->getServerLogoutURL();
        $paramSeparator = '?';
        if (isset($params['url'])) {
            $cas_url = $cas_url . $paramSeparator . "url=" . urlencode($params['url']);
            $paramSeparator = '&';
        }
        if (isset($params['service'])) {
            $cas_url = $cas_url . $paramSeparator . "service=" . urlencode($params['service']);
        }
        header('Location: ' . $cas_url);
        phpCAS::trace("Prepare redirect to : " . $cas_url);
        phpCAS::trace("Destroying session : " . session_id());
        session_unset();
        session_destroy();
        if (session_status() === PHP_SESSION_NONE) {
            phpCAS::trace("Session terminated");
        } else {
            phpCAS::error("Session was not terminated");
            phpCAS::trace("Session was not terminated");
        }
        $lang = $this->getLangObj();
        $this->printHTMLHeader($lang->getLogout());
        printf('<p>' . $lang->getShouldHaveBeenRedirected() . '</p>', $cas_url);
        $this->printHTMLFooter();
        phpCAS::traceExit();
        throw new CAS_GracefullTerminationException();
    }

Usage Example

示例#1
0
文件: CAS.php 项目: DCUnit711/Demeter
 /**
  * This method is used to logout from CAS. Halts by redirecting to the CAS
  * server.
  *
  * @param string $service a URL that will be transmitted to the CAS server
  * @param string $url     a URL that will be transmitted to the CAS server
  *
  * @return void
  *
  * @deprecated The url parameter has been removed from the CAS server as of
  * version 3.3.5.1
  */
 public static function logoutWithRedirectServiceAndUrl($service, $url)
 {
     trigger_error('Function deprecated for cas servers >= 3.3.5.1', E_USER_DEPRECATED);
     phpCAS::traceBegin();
     phpCAS::_validateClientExists();
     if (!is_string($service)) {
         phpCAS::error('type mismatched for parameter $service (should be `string\')');
     }
     if (!is_string($url)) {
         phpCAS::error('type mismatched for parameter $url (should be `string\')');
     }
     self::$_PHPCAS_CLIENT->logout(array("service" => $service, "url" => $url));
     // never reached
     phpCAS::traceEnd();
 }
CAS_Client