logger->log( LogLevel::ERROR, 'getCookieDomain: The regular expression for the cookie domain contains errors.' . 'The session is not shared across sub-domains.', ['cookieDomain' => $cookieDomain, 'errorCode' => 1399137882] ); } elseif ($matchCnt) { $result = $match[0]; } } else { $result = $cookieDomain; } } return $result; } /** * Sets the cookie * Protected function taken from t3lib_userAuth (t3 4.7.7) * * @param string $cookieName identifier for the cookie * @param string $cookieValue cookie value * @param int $cookieExpire expire time for the cookie (UNIX timestamp) * * @throws Exception */ public function setVoteCookie($cookieName, $cookieValue, $cookieExpire = 0): void { // do not set session cookies if (!empty($cookieExpire)) { $settings = $GLOBALS['TYPO3_CONF_VARS']['SYS']; // Get the domain to be used for the cookie (if any): $cookieDomain = $this->getCookieDomain(); // If no cookie domain is set, use the base path: $cookiePath = ($cookieDomain ? '/' : GeneralUtility::getIndpEnv('TYPO3_SITE_PATH')); // Use the secure option when the current request is served by a secure connection: $cookieSecure = (bool)$settings['cookieSecure'] && GeneralUtility::getIndpEnv('TYPO3_SSL'); // Deliver cookies only via HTTP and prevent possible XSS by JavaScript: $cookieHttpOnly = (bool)$settings['cookieHttpOnly']; // Do not set cookie if cookieSecure is set to "1" (force HTTPS) and no secure channel is used: if ((int)$settings['cookieSecure'] !== 1 || GeneralUtility::getIndpEnv('TYPO3_SSL')) { setcookie( $cookieName, $cookieValue, (int)$cookieExpire, $cookiePath, $cookieDomain, $cookieSecure, $cookieHttpOnly ); $this->cookieProtection = true; $this->logger->log( LogLevel::INFO, 'setVoteCookie: Cookie set', [ 'cookieName' => $cookieName, 'cookieValue' => $cookieValue, 'cookieExpire' => $cookieExpire, 'cookiePath' => $cookiePath, 'cookieDomain' => $cookieDomain, 'cookieSecure' => $cookieSecure, 'cookieHttpOnly' => $cookieHttpOnly, ] ); } else { throw new Exception( "Cookie was not set since HTTPS was forced in \$GLOBALS['TYPO3_CONF_VARS'][SYS][cookieSecure].", 1254325546 ); } } } /** * Return if cookie protection has been set * * @return bool */ public function isProtected() { return $this->cookieProtection; } }