You would create a front controller plugin that would execute your short function on every request. If you only want to do it for logged in users, then you would add this plugin later in the stack, so that it executes after your login logic.
You would then get the logged in user using $auth = Zend_Auth::getInstance()
and $auth->getIdentity()
.
You should look here for how to create a Front Controller Plugin and read about how to use them.
The best article on Plugins - http://devzone.zend.com/article/3372
The documentation - http://framework.zend.com/manual/en/zend.controller.plugins.html
The "hook" points at our disposal are:
> routeStartup(): prior to routing the request
> routeShutdown(): after routing the request
> dispatchLoopStartup(): prior to entering the dispatch loop
> preDispatch(): prior to dispatching an individual action
> postDispatch(): after dispatching an individual action
> dispatchLoopShutdown(): after completing the dispatch loop
I won't tell you which to use, as you should know this the best from knowing how your application works.