Link to home
Start Free TrialLog in
Avatar of skij
skijFlag for Canada

asked on

PHP: Redirection Header Before Background Processes Complete

Using PHP, how can I send a redirect header first, then do something in the background after the browser has already be redirected?  

In the example below, even though the redirection is called for immediately, there is a 30 second pause before it occurs.
<?php
ignore_user_abort(true);
set_time_limit(0);
header('Location: http://www.example.com/');

sleep(30);

// do Something in the background

exit;
?>

Open in new window

SOLUTION
Avatar of Mark Brady
Mark Brady
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial