therealwesfoster Posted July 22, 2009 Share Posted July 22, 2009 Is there any way I can trigger a function if a page is about to timeout? Link to comment https://forums.phpfreaks.com/topic/167007-solved-custom-function-on-page-timeout/ Share on other sites More sharing options...
jamesxg1 Posted July 22, 2009 Share Posted July 22, 2009 Hiya, I dont fully understand what you are meaning here but maybe set a cookie or a session with a time in it and then go from there ?, James. Link to comment https://forums.phpfreaks.com/topic/167007-solved-custom-function-on-page-timeout/#findComment-880581 Share on other sites More sharing options...
therealwesfoster Posted July 22, 2009 Author Share Posted July 22, 2009 Lets say they page will timeout in 30 seconds (max execution time). If the page has been loading for 25 seconds (about to timeout) I would like to trigger a custom function. Here is some fake code that might explain what I want to do: <?php set_time_limit(30); if (page_load_time() > 25){ // Do Function } ?> Link to comment https://forums.phpfreaks.com/topic/167007-solved-custom-function-on-page-timeout/#findComment-880586 Share on other sites More sharing options...
therealwesfoster Posted July 23, 2009 Author Share Posted July 23, 2009 bump... this isn't me... i need some help, freaks Link to comment https://forums.phpfreaks.com/topic/167007-solved-custom-function-on-page-timeout/#findComment-880952 Share on other sites More sharing options...
Mark Baker Posted July 23, 2009 Share Posted July 23, 2009 function say_goodbye() { if (connection_aborted()) { echo 'script has been aborted by the user'; } elseif (connection_status() == CONNECTION_TIMEOUT) { echo 'script has timed out'; } else { echo 'script has finished normally'; } } register_shutdown_function("say_goodbye"); Link to comment https://forums.phpfreaks.com/topic/167007-solved-custom-function-on-page-timeout/#findComment-881032 Share on other sites More sharing options...
therealwesfoster Posted July 23, 2009 Author Share Posted July 23, 2009 function say_goodbye() { if (connection_aborted()) { echo 'script has been aborted by the user'; } elseif (connection_status() == CONNECTION_TIMEOUT) { echo 'script has timed out'; } else { echo 'script has finished normally'; } } register_shutdown_function("say_goodbye"); Wow, I'll test it out and let you know Link to comment https://forums.phpfreaks.com/topic/167007-solved-custom-function-on-page-timeout/#findComment-881267 Share on other sites More sharing options...
therealwesfoster Posted July 23, 2009 Author Share Posted July 23, 2009 Works beautifully. Thanks Mark. If I could give reps I would Link to comment https://forums.phpfreaks.com/topic/167007-solved-custom-function-on-page-timeout/#findComment-881280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.