--- cas_original.module	2012-03-05 01:30:35.000000000 +0100
+++ cas.module	2012-03-07 11:01:08.000000000 +0100
@@ -651,11 +651,10 @@ function cas_login_page($cas_first_login
  */
 function cas_logout($invoke_hook = TRUE) {
   global $user;
+  global $base_url;
 
   // 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
@@ -665,17 +664,12 @@ function cas_logout($invoke_hook = TRUE)
     $destination = $_GET['destination'];
   }
   else {
-    $destination = variable_get('cas_logout_destination', '');
+    $destination = variable_get('cas_logout_destination', $base_url);
   }
 
   //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,9 @@ function cas_logout($invoke_hook = TRUE)
   }
   session_destroy();
 
-  // Force redirection in drupal_goto().
+  // Logout on cas server and redirect to drupal if logout redirects is enabled on cas server.
   unset($_GET['destination']);
-  drupal_goto($logout_url, $options);
+  phpCAS::logoutWithRedirectService($destination_url);	//marco
 }
 
 /**
