Hello guys,
I have this in my main controller:
<?php
namespace Tendcom\Controllers;
use Phalcon\Mvc\Controller;
use Tendcom\Library\Acl;
use Tendcom\Library\Menu;
use Tendcom\Models\Users\Users;
class ControllerBase extends Controller {
public function initialize() {
// set template
$this->view->setTemplateAfter('tendcom');
$this->getAssets();
// set test active
$this->view->isTest = ($this->config->isTest) ? true : null;
// get url
$baseUri = $this->url->getBaseUri();
$this->view->baseUri = $baseUri;
// verify if session exists
if(!$this->session->get('userTendcom')) {
header('Location: /login');
return false;
}
// get user profile
$user = $this->session->get('userTendcom');
$this->view->user = $user;
and this in another controller:
<?php
namespace Tendcom\Controllers\B2w;
use Tendcom\Controllers\ControllerBase;
use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Hidden;
use Phalcon\Forms\Element\Submit;
class B2wController extends ControllerBase {
public function initialize() {
parent::initialize();
}
public function indexAction() {
echo $user['id'];exit;
}
I call $user variable in indexAction, but not working, see that the $user variable was initialized in main controller.
what's happening?
I have this reference: https://docs.phalcon.io/en/latest/controllers#initializing-controllers
I need help for understand.
Thanks