J
J
jorshjorsh952018-07-22 16:48:10
1C-Bitrix
jorshjorsh95, 2018-07-22 16:48:10

COOKIES are not displayed in the Bitrix template?

Good afternoon, in general:
1. I set a cookie in js
2. I get it in the Bitrix component template via $_COOKIE['NAME']
And it works every time, for example: I
made a simple output var_dump($_COOKIE['NAME']) , and the result is either cached or NULL output (although if you look through the developer panel in Application->cookie, everything is set there as it should.
Most likely it's a dirty thing with component caching, but I can't be sure that such things are cached in Bitrix.
ps I tried to get a cookie via $APPLICATION->get_cookie('NAME') - but it doesn't work
Help, tell me how to be and what to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2021-04-14
@vaajnur

when composite is enabled, cookies are cached like all other superglobal variables.
use

$frame = new \Bitrix\Main\Page\FrameBuffered("my_dynamic"); // или $this->createFrame() в шаблоне
$frame->begin();
  // Содержание динамической области
$frame->beginStub();
  // Заглушка
$frame->end();

to cancel the cache by the
way - here you need to receive without a prefix (2nd parameter).
$APPLICATION->get_cookie('NAME', false)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question