Mercurial > hg > cmmr2012-drupal-site
view core/tests/Drupal/Tests/SessionTestTrait.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
line wrap: on
line source
<?php namespace Drupal\Tests; use Symfony\Component\HttpFoundation\Request; /** * Provides methods to generate and get session name in tests. */ 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; } }