I met a very strange question, I wrote a controllerbase. When I use $this->cookies->set and forward in the initialize method of the base class are not work there is no error, but in other places use is OK, and elsewhere is inherited from the base class
use Phalcon\Mvc\Controller;
class ControllerBase extends Controller
{
static $redis = null;
public $number;
public function initialize()
{
if(!$this->cookies->has('number'))
{
$number = uniqid();
$this->cookies->set('number',$number,time()+30*86400,'/');
}
$number = $this->cookies->get('number')->getValue();
if(!$this->getRedisInstance()->exists($number.'_address'))
{
$this->dispatcher->forward(array(
'controller' => 'school',
'action' => 'select'
));
}
$this->number = $number;
if(method_exists($this, '_init'))
$this->_init();
}
static public function getRedisInstance ()
{
if(!self::$redis)
{
$frontCache = new \Phalcon\Cache\Frontend\Data(array(
'lifetime' => 2678400,
));
$cache = new Phalcon\Cache\Backend\Redis($frontCache,array(
'host' => 'localhost',
'port' => 6379,
// 'auth' => 'foobared',
'persistent' => false,
));
self::$redis = $cache;
}
return self::$redis;
}
}