On one of the sites I manage, when the administrator logs in it triggers a bunch of automated processes that check order status, send reminder emails and so on. This can take a while - 30 seconds or more - and currently it interrupts the login process, while the user waits for the processes to complete.
if (isset($_POST['submit']) && isset($_POST['login']))
{
require_once(ADMIN_INCLUDE_PATH . 'classes/adminLogin.class.php');
$login = new adminLogin;
if($login->tryLogin())
{
// Flush old CartItems
require_once(ADMIN_INCLUDE_PATH . 'classes/flushOldCartItems.class.php');
$flusher = new flushOldCartItems;
$flusher->flush();
// Send auto reminder emails to Vendors
require_once(ADMIN_INCLUDE_PATH . 'classes/emailBatchVendorRemind.class.php');
$batch = new emailBatchVendorRemind;
$batch->doBatchEmail();
// Send membership renewal reminders to Customers
require_once(ADMIN_INCLUDE_PATH . 'classes/emailBatchMemberReminders.class.php');
$batch = new emailBatchMemberReminders();
$batch->sendBatchReminders();
// Send class reminder to any live class enrollees
require_once(ADMIN_INCLUDE_PATH . 'classes/emailBatchLiveClassReminders.class.php');
$batch = new emailBatchLiveClassReminders();
$batch->sendBatchReminders();
// Send registration reminder to any un-registered webcast enrollees
require_once(ADMIN_INCLUDE_PATH . 'classes/emailBatchWebReminders.class.php');
$batch = new emailBatchWebReminders();
$batch->sendBatchReminders();
}
}
// and then we display "logged in" screen & navigation
I was thinking it would be nice if instead the processes could just be "triggered" by the login process, rather than happening "in line", and continue running even if the user then navigates to another page in the admin.
Is there a way to trigger another script that can do all this in the background, so to speak? As if it were being loaded in another window and left to run, but without opening another window.
Does this make sense?