Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SessionConfiguration.php

function SessionConfiguration::getUnprefixedName

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

Parameters

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

Return value

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

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 90

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() . $this->options['name_suffix'];
        // 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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal