Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.113
diff -u -9 -p -r1.113 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	4 Jun 2009 03:33:28 -0000	1.113
+++ modules/simpletest/drupal_web_test_case.php	6 Jun 2009 14:30:14 -0000
@@ -941,23 +941,22 @@ class DrupalWebTestCase extends DrupalTe
   protected function drupalGetToken($value = '') {
     $private_key = drupal_get_private_key();
     return md5($this->session_id . $value . $private_key);
   }
 
   /*
    * Logs a user out of the internal browser, then check the login page to confirm logout.
    */
   protected function drupalLogout() {
-    // Make a request to the logout page.
-    $this->drupalGet('user/logout');
-
-    // Load the user page, the idea being if you were properly logged out you should be seeing a login screen.
-    $this->drupalGet('user');
+    // Make a request to the logout page, and redirect to the user page, the
+    // idea being if you were properly logged out you should be seeing a login
+    // screen.
+    $this->drupalGet('user/logout', array('query' => 'destination=user'));
     $pass = $this->assertField('name', t('Username field found.'), t('Logout'));
     $pass = $pass && $this->assertField('pass', t('Password field found.'), t('Logout'));
 
     if ($pass) {
       $this->loggedInUser = FALSE;
     }
   }
 
   /**
Index: modules/simpletest/tests/session.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/session.test,v
retrieving revision 1.14
diff -u -9 -p -r1.14 session.test
--- modules/simpletest/tests/session.test	2 Jun 2009 06:58:17 -0000	1.14
+++ modules/simpletest/tests/session.test	6 Jun 2009 14:30:14 -0000
@@ -199,18 +199,19 @@ class SessionTestCase extends DrupalWebT
 
   /**
    * Reset the cookie file so that it refers to the specified user.
    *
    * @param $uid User id to set as the active session.
    */
   function sessionReset($uid = 0) {
     // Close the internal browser.
     $this->curlClose();
+    $this->loggedInUser = FALSE;
 
     // Change cookie file for user.
     $this->cookieFile = file_directory_temp() . '/cookie.' . $uid . '.txt';
     $this->additionalCurlOptions[CURLOPT_COOKIEFILE] = $this->cookieFile;
     $this->additionalCurlOptions[CURLOPT_COOKIESESSION] = TRUE;
     $this->drupalGet('session-test/get');
     $this->assertResponse(200, t('Session test module is correctly enabled.'), t('Session'));
   }
 
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.39
diff -u -9 -p -r1.39 user.pages.inc
--- modules/user/user.pages.inc	5 Jun 2009 09:26:06 -0000	1.39
+++ modules/user/user.pages.inc	6 Jun 2009 14:30:14 -0000
@@ -130,20 +130,22 @@ function user_pass_reset(&$form_state, $
 
 /**
  * Menu callback; logs the current user out, and redirects to the home page.
  */
 function user_logout() {
   global $user;
 
   watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
 
-  // Destroy the current session:
+  // Destroy the current session.
   session_destroy();
+  $_SESSION = array();
+
   module_invoke_all('user_logout', NULL, $user);
 
   // Load the anonymous user
   $user = drupal_anonymous_user();
 
   drupal_goto();
 }
 
 /**
