More updates to stop using dev or alpha or beta versions.
[yaffs-website] / web / core / tests / Drupal / Tests / SessionTestTrait.php
1 <?php
2
3 namespace Drupal\Tests;
4
5 use Symfony\Component\HttpFoundation\Request;
6
7 /**
8  * Provides methods to generate and get session name in tests.
9  */
10 trait SessionTestTrait {
11
12   /**
13    * The name of the session cookie.
14    *
15    * @var string
16    */
17   protected $sessionName;
18
19   /**
20    * Generates a session cookie name.
21    *
22    * @param string $data
23    *   The data to generate session name.
24    */
25   protected function generateSessionName($data) {
26     $prefix = (Request::createFromGlobals()->isSecure() ? 'SSESS' : 'SESS');
27     $this->sessionName = $prefix . substr(hash('sha256', $data), 0, 32);
28   }
29
30   /**
31    * Returns the session name in use on the child site.
32    *
33    * @return string
34    *   The name of the session cookie.
35    */
36   protected function getSessionName() {
37     return $this->sessionName;
38   }
39
40 }