CodeIgniter: Controller Life Cycle

The text is quite long, the question is actually simple and written in bold . Another text is intended only to explain the problem.

I recently started using CodeIgniter to develop my site. I am currently writing a side menu where you can filter the items shown in the view (basic e-commerce features).

The idea that I had was to have an array in my Shop-Control, where I store my filter values, which are also transferred from my filter, so several types of filters are processed in the kan filter menu.

The problem is that the controller constructor is launched every time the controller is called. I thought that the controller was built only once when the user logs into the website. I'm pretty new to devlopment and basically C ++ is a guy, so this seems a little odd to me.

My question is pretty simple: Is it true that the controller instance is created with every call to the controller function? Otherwise, what am I doing wrong to make the controller instance be restored every time the controller is called ...

I hope my question is not too blurry. It is important for me to understand the CodeIgniter life cycle behavior in order to be able to find a simple solution for this. I would like to avoid using $ _SESSION because I would like to use a solution like OOP.

+3
2

, ? , , ..

, , . CodeIgniter , , ( , ++). , , - (). - cookie. cookie.

$_SESSION , . , , , ( ).

+3

, ? ? , $this- > load- > model ('the_model'), ? / ?

private $instance;

function init_model() {
    if ($this->instance === NULL) {
        $this->instance = array();
    }
    return $this->instance;
}

init_model , , $instance ()?

0

Source: https://habr.com/ru/post/1773517/


All Articles