You are here

protected function SessionConfiguration::getUnprefixedName in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Session/SessionConfiguration.php \Drupal\Core\Session\SessionConfiguration::getUnprefixedName()

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.

1 call to SessionConfiguration::getUnprefixedName()
SessionConfiguration::getName in core/lib/Drupal/Core/Session/SessionConfiguration.php
Returns the session cookie name.

File

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

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);
}