22 public function __construct($name, $value, $expires =
null, $addPrefix =
true)
24 $this->name = ($addPrefix ? static::generateCookieName($name) : $name);
25 $this->originalName = $name;
26 $this->value = $value;
27 $this->expires = ($expires ===
null ? time() + 31104000 : $expires);
28 $this->spread = static::SPREAD_DOMAIN | static::SPREAD_SITES;
94 static $domain =
null;
101 $request = \Bitrix\Main\Context::getCurrent()->getRequest();
103 $httpHost = $request->getHttpHost();
105 $cacheFlags = Config\Configuration::getValue(
'cache_flags');
106 $cacheTtl = ($cacheFlags[
'site_domain'] ?? 0);
108 if ($cacheTtl ===
false)
110 $connection = \Bitrix\Main\Application::getConnection();
111 $sqlHelper = $connection->getSqlHelper();
113 $sql =
"SELECT DOMAIN ".
114 "FROM b_lang_domain ".
115 "WHERE '".$sqlHelper->forSql(
'.'.$httpHost).
"' like ".$sqlHelper->getConcatFunction(
"'%.'",
"DOMAIN").
" ".
116 "ORDER BY ".$sqlHelper->getLengthFunction(
"DOMAIN").
" ";
117 $recordset = $connection->query($sql);
118 if ($record = $recordset->fetch())
120 $domain = $record[
'DOMAIN'];
125 $managedCache = \Bitrix\Main\Application::getInstance()->getManagedCache();
127 if ($managedCache->read($cacheTtl,
'b_lang_domain',
'b_lang_domain'))
129 $arLangDomain = $managedCache->get(
'b_lang_domain');
133 $arLangDomain = [
'DOMAIN' => [],
'LID' => []];
135 $connection = \Bitrix\Main\Application::getConnection();
136 $sqlHelper = $connection->getSqlHelper();
138 $recordset = $connection->query(
140 "FROM b_lang_domain ".
141 "ORDER BY ".$sqlHelper->getLengthFunction(
"DOMAIN")
143 while ($record = $recordset->fetch())
146 $arLangDomain[
'DOMAIN'][] = $record;
147 $arLangDomain[
'LID'][$record[
'LID']][] = $record;
149 $managedCache->set(
'b_lang_domain', $arLangDomain);
152 foreach ($arLangDomain[
'DOMAIN'] as $record)
154 if (strcasecmp(mb_substr(
'.'.$httpHost, -(mb_strlen($record[
'DOMAIN']) + 1)),
".".$record[
'DOMAIN']) == 0)
156 $domain = $record[
'DOMAIN'];
162 if ($domain ===
null)