beforeFilter(): beforeFilter function run before every action in the controller. It’s the right place to check for an active session or inspect user permissions.afterFilter(): afterFilter function called after every controller action but after rendering is done. It is the last controller method to run.