You are here

public function CookieHelper::getCookieName in Persistent Login 8

Returns the name of the persistent login cookie.

Parameters

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

Return value

string The cookie name.

Overrides CookieHelperInterface::getCookieName

2 calls to CookieHelper::getCookieName()
CookieHelper::getCookieValue in src/CookieHelper.php
Returns the value of the persistent login cookie.
CookieHelper::hasCookie in src/CookieHelper.php
Checks if a request contains a persistent login cookie.

File

src/CookieHelper.php, line 44

Class

CookieHelper
Cookie helper service.

Namespace

Drupal\persistent_login

Code

public function getCookieName(Request $request) {
  $prefix = $this->configFactory
    ->get('persistent_login.settings')
    ->get('cookie_prefix');

  // Use different session identifiers for HTTPS and HTTP to prevent a cookie
  // collision.
  // @see \Drupal\Core\Session\SessionConfiguration::getName()
  if ($request
    ->isSecure()) {
    $prefix = 'S' . $prefix;
  }
  $sessionConfigurationSettings = $this->sessionConfiguration
    ->getOptions($request);

  // Replace the session cookie prefix.
  $session_name = preg_replace('/^S?SESS/', '', $sessionConfigurationSettings['name']);
  return $prefix . $session_name;
}