diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index db0f09f..bfcc441 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -484,13 +484,30 @@ abstract class WebTestBase extends TestBase {
    *   $account->pass_raw = $pass_raw;
    * @endcode
    *
-   * @param $user
-   *   User object representing the user to log in.
+   * @param object $user
+   *   The user account to log in.
+   * @param bool $create_concurrent_session
+   *   (optional) Whether to create a new, concurrent user session. Pass TRUE
+   *   for first login. Defaults to FALSE, which means that the currently logged
+   *   in user, if logged in, is logged out and back in (default behavior).
    *
    * @see drupalCreateUser()
    */
-  protected function drupalLogin($user) {
-    if ($this->loggedInUser) {
+  protected function drupalLogin($user, $create_concurrent_session = FALSE) {
+    // If we're asked to create a new session, unset the current.
+    if ($create_concurrent_session) {
+      unset($this->curlHandle);
+      $this->loggedInUser = FALSE;
+    }
+    // If there is a session attached on $user already, try to use that directly.
+    elseif ($this->drupalSwitchUser($user)) {
+      $this->verbose($this->drupalGetcontent());
+      $this->pass(t('User %name is still logged in.', array('%name' => $user->name)), t('User login'));
+      return;
+    }
+
+    // If we are logged in already and are asked to re-login, log out first.
+    if ($this->loggedInUser && $this->loggedInUser->uid == $user->uid) {
       $this->drupalLogout();
     }
 
@@ -505,11 +522,41 @@ abstract class WebTestBase extends TestBase {
     $pass = $this->assertLink(t('Log out'), 0, t('User %name successfully logged in.', array('%name' => $user->name)), t('User login'));
 
     if ($pass) {
+      // Save the user's session on the account itself.
+      if (!isset($user->session)) {
+        $user->session = new stdClass;
+      }
+      $user->session->curlHandle = $this->curlHandle;
+
+      // Switch the currently logged in user.
       $this->loggedInUser = $user;
     }
   }
 
   /**
+   * Switches the session of the internal browser to the one provided in a given user account.
+   *
+   * @param object $account
+   *   The user account object containing internal browser session data (set up
+   *   by WebTestBase::drupalLogin()) to switch to.
+   *
+   * @see WebTestBase::drupalLogin()
+   */
+  protected function drupalSwitchUser($account) {
+    if (isset($account->session)) {
+      // Switch to the user session.
+      $this->loggedInUser = $account;
+      $this->curlHandle = $account->session->curlHandle;
+
+      // Restore internal browser state of the user.
+      // Updates content properties on $this as well as $this->loggedInUser.
+      $this->drupalSetContent($account->session->content, $account->session->url);
+      return TRUE;
+    }
+    return FALSE;
+  }
+
+  /**
    * Generate a token for the currently logged in user.
    */
   protected function drupalGetToken($value = '') {
@@ -519,8 +566,17 @@ abstract class WebTestBase extends TestBase {
 
   /*
    * Logs a user out of the internal browser, then check the login page to confirm logout.
+   *
+   * @param object $account
+   *   (optional) The user account to log out.
    */
-  protected function drupalLogout() {
+  protected function drupalLogout($account = NULL) {
+    // If a specific account was passed, ensure that we are operating on that
+    // user's session first.
+    if (isset($account) && (!$this->loggedInUser || $account->uid != $this->loggedInUser)) {
+      $this->drupalSwitchUser($account);
+    }
+
     // 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.
@@ -530,6 +586,13 @@ abstract class WebTestBase extends TestBase {
     $pass = $pass && $this->assertField('pass', t('Password field found.'), t('Logout'));
 
     if ($pass) {
+      // Remove the user's session on the account itself.
+      if (isset($account->session->curlHandle)) {
+        curl_close($account->session->curlHandle);
+      }
+      unset($account->session);
+
+      // Switch to no session.
       $this->loggedInUser = FALSE;
     }
   }
@@ -2085,6 +2148,13 @@ abstract class WebTestBase extends TestBase {
     if (preg_match('/jQuery\.extend\(Drupal\.settings, (.*?)\);/', $content, $matches)) {
       $this->drupalSettings = drupal_json_decode($matches[1]);
     }
+    // Clone the relevant results onto the currently logged in user
+    // account/session.
+    if (isset($this->loggedInUser->session)) {
+      $this->loggedInUser->session->url = $this->url;
+      $this->loggedInUser->session->content = $this->content;
+      $this->loggedInUser->session->drupalSettings = $this->drupalSettings;
+    }
   }
 
   /**
diff --git a/core/modules/simpletest/simpletest.test b/core/modules/simpletest/simpletest.test
index cc4e026..c30229c 100644
--- a/core/modules/simpletest/simpletest.test
+++ b/core/modules/simpletest/simpletest.test
@@ -708,3 +708,66 @@ class SimpleTestOtherInstallationProfileModuleTestsTestCase extends WebTestBase
     $this->assertNoText('Installation profile module tests helper');
   }
 }
+
+class ConflictSwitchExampleTestCase extends WebTestBase {
+  public static function getInfo() {
+    return array(
+      'name' => 'drupalSwitchUser() example',
+      'description' => 'Demonstrates drupalSwitchUser() usage.',
+      'group' => 'Conflict',
+    );
+  }
+
+  function setUp() {
+    parent::setUp();
+    // Create two web users.
+    $this->user1 = $this->drupalCreateUser();
+    $this->user2 = $this->drupalCreateUser();
+  }
+
+  function testConcurrentLogin() {
+    // Login first user.
+    $this->drupalLogin($this->user1);
+    $this->assertText($this->user1->name);
+    $this->clickLink(t('Edit'));
+
+    // Login second user.
+    // Without passing TRUE, the first user would be logged out.
+    $this->drupalLogin($this->user2, TRUE);
+    $this->assertText($this->user2->name);
+    $this->clickLink(t('Edit'));
+
+    // Switch to first user.
+    $this->drupalLogin($this->user1);
+    // Verify that we ARE user1 and SEE what user1 saw before.
+    $this->assertText($this->user1->name);
+    $this->assertFieldByName('mail', $this->user1->mail);
+
+    // Switch to second user.
+    $this->drupalLogin($this->user2);
+    // Verify that we ARE user2 and SEE what user2 saw before.
+    $this->assertText($this->user2->name);
+    $this->assertFieldByName('mail', $this->user2->mail);
+
+    // Log out second user.
+    $this->drupalLogout();
+
+    // Switch back to first user and confirm that we're still logged in.
+    $this->drupalLogin($this->user1);
+    // Verify that we ARE user1 and SEE what user1 saw before.
+    $this->assertText($this->user1->name);
+    $this->assertFieldByName('mail', $this->user1->mail);
+
+    // Log the second user back in (was logged out above).
+    // Without passing TRUE, the first user would be logged out.
+    $this->drupalLogin($this->user2, TRUE);
+    $this->assertText($this->user2->name);
+    $this->clickLink(t('Edit'));
+
+    // Switch back to first user once more.
+    $this->drupalLogin($this->user1);
+    // Verify that we ARE user1 and SEE what user1 saw before.
+    $this->assertText($this->user1->name);
+    $this->assertFieldByName('mail', $this->user1->mail);
+  }
+}
