protected function SessionConfiguration::getUnprefixedName

protected SessionConfiguration::getUnprefixedName(Request $request)

Returns the session cookie name without the secure/insecure prefix.

@returns string The session name without the prefix (SESS/SSESS).

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request.

File

core/lib/Drupal/Core/Session/SessionConfiguration.php, line 85

Class

SessionConfiguration
Defines the default session configuration generator.

Namespace

Drupal\Core\Session

Code

protected function getUnprefixedName(Request $request) {
  if ($test_prefix = $this->drupalValidTestUa()) {
    $session_name = $test_prefix;
  }
  elseif (isset($this->options['cookie_domain'])) {
    // If the user specifies the cookie domain, also use it for session name.
    $session_name = $this->options['cookie_domain'];
  }
  else {
    // Otherwise use $base_url as session name, without the protocol
    // to use the same session identifiers across HTTP and HTTPS.
    $session_name = $request->getHost() . $request->getBasePath();
    // Replace "core" out of session_name so core scripts redirect properly,
    // specifically install.php.
    $session_name = preg_replace('#/core$#', '', $session_name);
  }

  return substr(hash('sha256', $session_name), 0, 32);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Session!SessionConfiguration.php/function/SessionConfiguration::getUnprefixedName/8.1.x