Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Saving persistent data

Is saving persistent data like an array of objects... in $this->persistent->myData in controllers is a good way , and is it stored in the RAM of the servers.



29.4k
Accepted
answer

No it is saved in your session. You need to initialize session first to use $this->persistent.

for example:

class DictionaryController extends \Phalcon\Mvc\Controller
{
    public function indexAction()
    {
        $this->persistent->testing_key = "my test value";
        $this->response->redirect("dictionary/show");
    }

    public function showAction()
    {
        $this->view->disable();
        echo "<pre>";
        print_r($_SESSION);
    }
}

you get

Array
(
    [_started] => 1
    [DictionaryController] => Array
        (
            [testing_key] => my test value
        )
)

Persistent makes Class name session key and add to it key=>value



14.3k
edited Apr '14

in the tutorial of INVO project, in the Security Plugin, they saved the ACL in the $this->persistent. Which is the same for all users!