Get cookie name with prefix and domain hash
@param string $cookieName
@return string
164252
protected function getCookieName($cookieName)
    {
        // NOTE: If the cookie name is changed, we must also update the method in piwik.js with the same name.
        $hash = substr(
            sha1(
                ($this->configCookieDomain == '' ? self::getCurrentHost() : $this->configCookieDomain) . $this->configCookiePath
            ),
            0,
            4
        );

        return self::FIRST_PARTY_COOKIES_PREFIX . $cookieName . '.' . $this->idSite . '.' . $hash;
    }
974773
public static function GetAuthCookieValue ($name = self::DEFAULT_CONNECTION_NAME) {
		$options = static::GetAuthCookieOptions($name);

		$cookie_name_prefix	= $options['cookie_name_prefix'];
		$cookie_name_safix	= $options['cookie_name_safix'];

		$cookie_pattern	= sprintf("/^%s.+%s$/", $cookie_name_prefix, $cookie_name_safix);
		foreach (Request::GetCookies() as $name => $value) {
			if (preg_match($cookie_pattern, $name, $matches) !== 0) {
				return [$matches[0], $value];
			}
		}
		return null;
	}
528091
public function cookie(string $key): string
    {
        if (array_key_exists($key, $this->cookies)) {
            return $this->decryptor->decrypt($this->cookies[$key]);
        }

        return '';
    }
155638
public function get($name = '')
    {
        $result = '';
        if (isset($_COOKIE[$name])) {
            $result = $_COOKIE[$name];
        }

        return $result;
    }
348635
protected function computeCredentialsName($prefix = null) {
		if (!$prefix) {
			$paths = $this->get('paths');
			if ($paths && isset($paths['default'])) {
				$prefix = $paths['default'];
			}
		}
		preg_match('/([http:\/\/|https:\/\/|ssh:\/\/])*(\w@)*([\w\.\-_]{1,}+)/', $prefix, $prefix);
		if (count($prefix)) return end($prefix);
		return basename($this->repository->getDir());
    }
356816
private function getSessionName($sessionName, SiteAccess $siteAccess)
    {
        // Add session prefix if needed.
        if (strpos($sessionName, static::SESSION_NAME_PREFIX) !== 0) {
            $sessionName = static::SESSION_NAME_PREFIX . '_' . $sessionName;
        }

        // Check if uniqueness marker is present. If so, session name will be unique for current siteaccess.
        if (strpos($sessionName, self::MARKER) !== false) {
            $sessionName = str_replace(self::MARKER, md5($siteAccess->name), $sessionName);
        }

        return $sessionName;
    }
511190
public static function getUserClassName($className)
    {
        if (null === self::$inflector) {
            static::$inflector = new ProxyManagerClassNameInflector('');
        }

        return static::$inflector->getUserClassName($className);
    }
505132
public Cookie getCookie( String cookieName )
    {
        List cookies = getHeaders(SET_COOKIE);
        if(cookies != null){
            // start looking from the back (ie. the last cookie set)
            for(int i = cookies.size(); --i > -1;) {
                Cookie cookie = (Cookie)cookies.get(i);
                if(cookie.getName().equals(cookieName)) {
                    return cookie;
                }
            }
        }

        return null;
    }
4131
public function getUsername($username)
    {
        if ($this->isValidUserDn($username)) {
            return $username;
        }
        $replacements = [
            $username,
            $this->config->getDomainName(),
        ];

        return preg_replace($this->params, $replacements, $this->bindFormat);
    }
777817
protected function getAllRouteNames($resourceName = null)
    {
        $resourceName = $resourceName ?? $this->resourceName;

        return [
            'index'   => $this->prefix.$this->resourceName.'.index',
            'create'  => $this->prefix.$this->resourceName.'.create',
            'store'   => $this->prefix.$this->resourceName.'.store',
            'show'    => $this->prefix.$this->resourceName.'.show',
            'edit'    => $this->prefix.$this->resourceName.'.edit',
            'update'  => $this->prefix.$this->resourceName.'.update',
            'destroy' => $this->prefix.$this->resourceName.'.destroy',
        ];
    }
1022719
public static function encodeDomainName($domain): string
    {
        if ('.' === $domain) {
            return chr(0);
        }

        $domain = rtrim($domain, '.').'.';
        $res = '';

        foreach (explode('.', $domain) as $label) {
            $res .= chr(strlen($label)).$label;
        }

        return $res;
    }
1294172
private static function serializePHPCookies(string $cookieName, $cookieValue): string
    {
        $cookieParts = [];
        $urlEncodedCookieName = urlencode($cookieName);
        $valueType = gettype($cookieValue);
        switch ($valueType) {
            case 'integer':
            case 'double':
            case 'string':
                $urlEncodedCookieValue = urlencode((string) $cookieValue);
                $cookieParts[] = "$urlEncodedCookieName=$urlEncodedCookieValue";
                break;

            case 'array':
                foreach ($cookieValue as $cookieValueKey => $cookieValueValue) {
                    $cookieParts[] = self::serializePHPCookies($cookieName."[$cookieValueKey]", $cookieValueValue);
                }
                break;

            case 'NULL':
                $cookieParts[] = "$urlEncodedCookieName=";
                break;

            case 'boolean':
                $cookieParts[] = "$urlEncodedCookieName=".((bool) $cookieValue ? '1' : '0');
                break;

            // It's a security risk to serialize an object and send it as a cookie
            case 'object':
                // Intentional fallthrough
            default:
                $cookieParts[] = "$urlEncodedCookieName=".self::UNSUPPORTED_TYPE_VALUE;
                break;
        }

        return implode(';', $cookieParts);
    }
156190
public function pageName($pageName = null)
    {
        if (null === $pageName) {
            return $this->pageName;
        }

        $this->pageName = $pageName;

        return $this;
    }
1339730
public function getDomainName(): string
    {
        return $this->myDomainParts[count($this->myDomainParts) - 1] . ($this->myTld !== null ? '.' . $this->myTld : '');
    }
265145
private function matchesSubstring($cookieName)
    {
        Types::assert(['string' => [$cookieName]]);

        foreach ($this->cookieList as $forbidden)
        {
            if (strpos(strtolower($cookieName), $forbidden) !== false)
            {
                return true;
            }
        }

        return false;
    }
374877
protected function getKey($name)
    {
        if (empty($_COOKIE[$name])) {
            $key         = random_bytes(64); // 32 for encryption and 32 for authentication
            $cookieParam = session_get_cookie_params();
            $encKey      = base64_encode($key);
            setcookie(
                $name,
                $encKey,
                // if session cookie lifetime > 0 then add to current time
                // otherwise leave it as zero, honoring zero's special meaning
                // expire at browser close.
                ($cookieParam['lifetime'] > 0) ? time() + $cookieParam['lifetime'] : 0,
                $cookieParam['path'],
                $cookieParam['domain'],
                $cookieParam['secure'],
                $cookieParam['httponly']
            );
            $_COOKIE[$name] = $encKey;
        } else {
            $key = base64_decode($_COOKIE[$name]);
        }
        return $key;
    }
787972
protected function _getCacheId($prefix = 'minify')
    {
        $name = preg_replace('/[^a-zA-Z0-9\\.=_,]/', '', $this->selectionId);
        $name = preg_replace('/\\.+/', '.', $name);
        $name = substr($name, 0, 100 - 34 - strlen($prefix));
        $md5 = md5(serialize(array(
            Minify_SourceSet::getDigest($this->sources),
            $this->options['minifiers'],
            $this->options['minifierOptions'],
            $this->options['postprocessor'],
            $this->options['bubbleCssImports'],
            Minify::VERSION,
        )));

        return "{$prefix}_{$name}_{$md5}";
    }