--- cas_original.module	2012-03-05 01:30:35.000000000 +0100
+++ cas.module	2012-03-07 17:37:51.000000000 +0100
@@ -52,6 +52,7 @@ function cas_init() {
  */
 function cas_login_check($force_authentication = TRUE) {
   global $user;
+  
   if ($user->uid) {
     //Don't Login  because we already are
     return;
@@ -654,8 +655,6 @@ function cas_logout($invoke_hook = TRUE)
 
   // Build the logout URL.
   cas_phpcas_init();
-  $logout_url = phpCAS::getServerLogoutURL();
-  $options = array();
 
   if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
     // Add destination override so that a destination can be specified on the
@@ -671,11 +670,6 @@ function cas_logout($invoke_hook = TRUE)
   //Make it an absolute url.  This will also convert <front> to the front page.
   if ($destination) {
     $destination_url = url($destination, array('absolute' => TRUE));
-    $options['query'] = array(
-      'destination' => $destination_url,
-      'service' => $destination_url,
-      'url' => $destination_url,
-    );
   }
 
   // Mimic user_logout().
@@ -685,9 +679,8 @@ function cas_logout($invoke_hook = TRUE)
   }
   session_destroy();
 
-  // Force redirection in drupal_goto().
-  unset($_GET['destination']);
-  drupal_goto($logout_url, $options);
+  // Logout on cas server and redirect to drupal if logout redirects is enabled on cas server.
+  phpCAS::logoutWithRedirectService($destination_url);
 }
 
 /**
