trait SessionTestTrait
Same name in other branches
- 8.9.x core/modules/simpletest/src/SessionTestTrait.php \Drupal\simpletest\SessionTestTrait
- 8.9.x core/tests/Drupal/Tests/SessionTestTrait.php \Drupal\Tests\SessionTestTrait
- 10 core/tests/Drupal/Tests/SessionTestTrait.php \Drupal\Tests\SessionTestTrait
- 11.x core/tests/Drupal/Tests/SessionTestTrait.php \Drupal\Tests\SessionTestTrait
Provides methods to generate and get session name in tests.
Hierarchy
- trait \Drupal\Tests\SessionTestTrait
1 file declares its use of SessionTestTrait
- FunctionalTestSetupTrait.php in core/
lib/ Drupal/ Core/ Test/ FunctionalTestSetupTrait.php
File
-
core/
tests/ Drupal/ Tests/ SessionTestTrait.php, line 10
Namespace
Drupal\TestsView source
trait SessionTestTrait {
/**
* The name of the session cookie.
*
* @var string
*/
protected $sessionName;
/**
* Generates a session cookie name.
*
* @param string $data
* The data to generate session name.
*/
protected function generateSessionName($data) {
$prefix = Request::createFromGlobals()->isSecure() ? 'SSESS' : 'SESS';
$this->sessionName = $prefix . substr(hash('sha256', $data), 0, 32);
}
/**
* Returns the session name in use on the child site.
*
* @return string
* The name of the session cookie.
*/
protected function getSessionName() {
return $this->sessionName;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
SessionTestTrait::$sessionName | protected | property | The name of the session cookie. |
SessionTestTrait::generateSessionName | protected | function | Generates a session cookie name. |
SessionTestTrait::getSessionName | protected | function | Returns the session name in use on the child site. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.