What is the correct way to set cookies from controller?
looking at the source code ,it must be something like this, but won't work.
$cook = new \Phalcon\Http\Response\Cookies();
$cook->setDI($this->getDI());
$cook->set('testook', 'testvalue', time()+60*60*24, '/');
and going through the whole source from $app->handle(), at the end there is call
PHALCON_CALL_METHOD_NORETURN(response, "sendheaders");
and $response->sendHeaders() call's send() only if $response->_headers != null
and then in $response->send()
PHALCON_OBS_VAR(cookies);
phalcon_read_property(&cookies, this_ptr, SL("_cookies"), PH_NOISY_CC);
if (Z_TYPE_P(cookies) != IS_NULL) {
PHALCON_CALL_METHOD_NORETURN(cookies, "send");
}
so $response->_cookies is internally set from $cook->set(...) call, BUT
PHALCON_CALL_METHOD_NORETURN(cookies, "send");
There is no send method in \Phalcon\Http\Response\Cookies :/ I've missed something?