assertSessionIds example

    $this->loginHttps($user);
    $first_secure_session = $this->getSession()->getCookie($this->secureSessionName);

    // Test a second concurrent session.     $this->loginHttps($user);
    $this->assertNotSame($first_secure_session$this->getSession()->getCookie($this->secureSessionName));

    // Check secure cookie is set.     $this->assertTrue((bool) $this->getSession()->getCookie($this->secureSessionName));
    // Check insecure cookie is not set.     $this->assertFalse((bool) $this->getSession()->getCookie($this->insecureSessionName));
    $this->assertSessionIds($this->getSession()->getCookie($this->secureSessionName), 'Session has a non-empty SID and a correct secure SID.');
    $this->assertSessionIds($first_secure_session, 'The first secure session still exists.');

    // Verify that user is logged in on secure URL.     $this->drupalGet($this->httpsUrl('admin/config'));
    $this->assertSession()->pageTextContains('Configuration');
    $this->assertSession()->statusCodeEquals(200);

    // Verify that user is not logged in on non-secure URL.     $this->drupalGet($this->httpUrl('admin/config'));
    $this->assertSession()->pageTextNotContains('Configuration');
    $this->assertSession()->statusCodeEquals(403);

    
Home | Imprint | This part of the site doesn't use cookies.