How to call a particular function in every page load

Hi ,

I want to call a particular function in every page load, currently i call this function from my layout like Utils::hitsave(); ,but when i load my page this function execute more than one time (more than one time data inserted into db in one refresh), i want know what is the correct way to call such functions (from BaseController / CController) like that.

add beforAction handler in your base controller class (by default it is Controller.php in approot/components) or create application behavior which handles beforeAction and attach it in main.php config file.

in base controller class, U can set afterAction or beforeRender

1 Like