We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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.



40.8k
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



22.8k
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!