How can I execute a PHP script from PHP without keeping the user on the page?
<p>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.</p>

<p>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.".</p>

<pre><code>&lt;?php
/* SESSION DATA HERE */
executeMailSend($ids);
?&gt;
&lt;html&gt;
&lt;head&gt;
....
&lt;/head&gt;
&lt;body&gt;
Your messages are being sent.
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>I think I could something like this using ajax, but I would prefer to not make this rely on client side coding.</p>

<p>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.</p>

<p>Also, I don't want to use anything like exec() or system().</p>

<p>Any ideas?</p>
