I am trying to trigger an event before a controller the action is called and even before the _construc function for that class is called.
I tried using cakephp beforeFilter, initialize and _construct method, didn't work as expected and i tried javascript code to trigger an event before the page is refreshed or reloads, but not working as expected. Here is the code i tried.
$(window).on('beforeLoad unload',function(){
$.get('http://www.antlax.com/provider/terminate');
});
I am expecting to terminate a process before the page is reloaded, so that at any giving time, there will be only one process for that page for all clients connected to the server.