<?php
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;
}
}
?>
Forward why not jump to the school controller? Instead, the default Index controller jumps