G
G
Grigory Vasilkov2017-05-28 19:24:53
Phalcon
Grigory Vasilkov, 2017-05-28 19:24:53

Why doesn't cookie work in Phalcon 3.1.2?

I can't send cookies to the user, I can't understand why
I create an i18n object, which I register in the allocator.

$di->setShared('i18n', function() use ($di) {
    $dispatcher = $di->getShared('dispatcher');
    $cookies = $di->getShared('cookies');

    $i18n_config = require_once __CONFIGSDIR__ . '/i18n.php';
    $i18n = new I18n($i18n_config, $dispatcher, $cookies);
    return $i18n;
  });

When an object constructor is called, a cookie with the language is set, but it is not set ... funny. If you request it via ->cookies->get()->getValue() - it is. But it's not in the browser. I mean - it's in PHP but not in reponse headers. If you put $this->cookies->send() - the cookie appears, but the i18n module is not the place to start displaying headers to the user.
I tried to put it before $response->send() in the bootstrap file - all the same, cookies do not reach the browser.
I seem to be misunderstanding DI in phalcon, can someone explain?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question