Hi, I'm building a site where the user enters some info into a form which submits to a php script. The php script takes a long time to execute (anywhere from 10 seconds to a minute) and when it finally finishes the page that it creates appears to get blocked by any firewall (tried on lots of different browsers/platforms) and you just get a completely blank page. (It's fine when just running on my local machine.)
I'm guessing that the script takes so long to execute that either the connection gets dropped (keep-alive timeout is set to 5, and I can't change it) or the firewall rejects the incoming data because the outgoing request was so long ago that it's forgotten about it.
I'm thinking that the solution is to use a 'please wait' page. So the user submits the form to my script, my script then sends back a session cookie along with a "Location: please_wait.php" header to redirect the user to the 'please wait' page. Whilst they're waiting, my php script does all its processing and sticks the info to be displayed into the $_SESSION array. The please wait page contains a <meta> tag that refreshes (after a few sceonds) to a php script that gets the info from the $_SESSION array and displays it.
And here's the question (at last!!)....
How do I get my script to send the session cookie and the "Location: " header, and THEN do it's processing? At the moment the form submits to a script like this:
[PHP]session_start();
header("Location: please_wait.php");
//do stuff that takes aaaaaages here
$_SESSION['stuff_to_display']=$stuff_that_the_script_made;[/PHP]
But the problem with it is that it doesn't send the header until it has done the processing. How do I get it to send the header and session cookie, and then do the processing? I've tried putting session_commit(); after the header(); line, but it doesn't help.
Any alternative solutions welcome as well.
Thanks