Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.11.2.3
diff -u -p -r1.11.2.3 user.pages.inc
--- modules/user/user.pages.inc	2 Jun 2010 12:03:07 -0000	1.11.2.3
+++ modules/user/user.pages.inc	17 Jan 2011 18:07:32 -0000
@@ -148,14 +148,25 @@ function user_logout() {
 
   watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
 
+  // Obtain the current session's attributes.
+  $p = session_get_cookie_params();
+
   // Destroy the current session:
   session_destroy();
+
+  // Re-create the current session cookie.
+  session_set_cookie_params($p['lifetime'], $p['path'], $p['domain'], $p['secure'], $p['httponly']);
+
+  // Start a new session.
+  session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy_sid', 'sess_gc');
+  session_start();
+
   // Only variables can be passed by reference workaround.
   $null = NULL;
   user_module_invoke('logout', $null, $user);
 
-  // Load the anonymous user
-  $user = drupal_anonymous_user();
+  // Load the anonymous user using the new session.
+  $user = drupal_anonymous_user(session_id());
 
   drupal_goto();
 }
