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

Destory Persistent

Can anyone tell me how I can manually destory a persistent variable, either from my browser or the server?

I forgot to comment out the caching from the ACL plugin:

if (!isset($this->persistent->acl)) {

and now my app's a bit broken and I cannot render any controllers or their views. Can anyone help with this?



1.7k
Accepted
answer
edited Feb '15

You can follow the guideline here https://docs.phalcon.io/en/latest/reference/acl.html#serializing-acl-lists

That is to serialize the Acl object and store in a text file, everytime you update your access control list rules, you can delete that file and the new Acl will be serialized and stored again.

//Check whether acl data already exist
if (!is_file("app/security/acl.data")) {

    $acl = new \Phalcon\Acl\Adapter\Memory();

    //... Define roles, resources, access, etc

    // Store serialized list into plain file
    file_put_contents("app/security/acl.data", serialize($acl));

} else {

     //Restore acl object from serialized file
     $acl = unserialize(file_get_contents("app/security/acl.data"));
}

@dzungcao awesome! Thanks for that, I also saw through the normal

$this->persistent 

that the data is stored in APC so I'll set that up so I can flush it while I'm still working in a dev enviroment :)