yous
@yous

Ошибка при установке Cookie?

Не ставятся куки на боевом сервере, на локальной машине всё нормально.

куки ставлю через ajax и компонент class

public function sendAction($signedParameters = ''){

....

$this->BASKET_SHARE_CODE = $this->generate_uuid();
$cookie = new Bitrix\Main\Web\Cookie("BASKET_SHARE_CODE", $this->BASKET_SHARE_CODE, time() + 60*60*24*30*12*2);
            $cookie->setDomain($context->getServer()->getHttpHost());
            $cookie->setHttpOnly(false);
            $cookie->setSecure(false);
            $context->getResponse()->addCookie($cookie);
            $context->getResponse()->flush("");

....


в логе такие ошибки

2024-02-13 10:21:30 - Host: site.com:443 - LOW_PRIORITY_ERROR - [ErrorException] E_WARNING
Cannot modify header information - headers already sent (0)
/home/bitrix/ext_www/site.com/bitrix/modules/main/lib/httpresponse.php:244
#0: setcookie(string, string, array)
	/home/bitrix/ext_www/site.com/bitrix/modules/main/lib/httpresponse.php:244
#1: Bitrix\Main\HttpResponse->setCookie(object)
	/home/bitrix/ext_www/site.com/bitrix/modules/main/lib/httpresponse.php:200
#2: Bitrix\Main\HttpResponse->writeHeaders()
	/home/bitrix/ext_www/site.com/bitrix/modules/main/lib/httpresponse.php:56
#3: Bitrix\Main\HttpResponse->flush(string)
	/home/bitrix/ext_www/site.com/bitrix/modules/main/lib/response.php:91
#4: Bitrix\Main\Response->send()
	/home/bitrix/ext_www/site.com/bitrix/modules/main/lib/engine/response/json.php:103
#5: Bitrix\Main\Engine\Response\Json->send()
	/home/bitrix/ext_www/site.com/bitrix/modules/main/lib/application.php:270
#6: Bitrix\Main\Application->end(integer, object)
	/home/bitrix/ext_www/site.com/bitrix/modules/main/lib/httpapplication.php:177
#7: Bitrix\Main\HttpApplication->finalizeControllerResult(object, array, object)
	/home/bitrix/ext_www/site.com/bitrix/modules/main/lib/httpapplication.php:155
#8: Bitrix\Main\HttpApplication->runController(object, string)
	/home/bitrix/ext_www/site.com/bitrix/modules/main/lib/httpapplication.php:113
#9: Bitrix\Main\HttpApplication->run()
	/home/bitrix/ext_www/site.com/bitrix/modules/main/services/ajax.php:29
#10: require(string)
	/home/bitrix/ext_www/site.com/bitrix/services/main/ajax.php:1
----------
  • Вопрос задан
  • 45 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы