Answer the question
In order to leave comments, you need to log in
Why are cookies not being written?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
use Bitrix\Main\Application;
use Bitrix\Main\Web\Cookie;
$application = Application::getInstance();
$context = $application->getContext();
$cookie = new Cookie("CARD_NUMBER", substr($_POST["phone"], 1), time() + 60*60*24*30*12*2);
$cookie->setDomain($context->getServer()->getHttpHost());
$cookie->setHttpOnly(false);
$context->getResponse()->addCookie($cookie);
$context->getResponse()->flush("");
Answer the question
In order to leave comments, you need to log in
use Bitrix\Main\Application;
use Bitrix\Main\Web\Cookie;
$context = Application::getInstance()->getContext();
$cookie = new Cookie("CARD_NUMBER", $card, 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("");
I call this script via ajax jquery.- Are these cookies present in the response?
$cookie->setSecure(false);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question