I have a script to process sending emails. There could be thousands of emails to send. I want to show the user a page that says something along the lines of "Your messages are being sent.", but I don't want that page to do the actual sending of the messages, because I don't want the user to see a blank page until the script finishes and I also don't want the user to have to wait for the script to finish.
I would like to pass a list of IDs to another PHP page (lets call it run.php) and have it execute without having the user actually visit it. So I would pass the IDs to the page, which starts the execution, but then finishes loading the current page which shows the message "Your messages are being sent.".
<?php
/* SESSION DATA HERE */
executeMailSend($ids);
?>
<html>
<head>
....
</head>
<body>
Your messages are being sent.
</body>
</html>
I think I could something like this using ajax, but I would prefer to not make this rely on client side coding.
Also, if at all possible, I need to have the script running in the background keep session data from the session that starts it, and I would prefer that I don't have to pass this data along as separate variables.
Also, I don't want to use anything like exec() or system().
Any ideas?