スクリプトでユーザーをできるだけ早くリダイレクトし、ユーザーがリダイレクトされた後もデータの処理を続行する必要があります。私はグーグルでこれを見つけましたが、うまくいきません。リダイレクトする前に 10 秒間待機します。ブラウザが直接アクセスできるようになる前に、ユーザーはスクリプトが終了するまで待つ必要があるようです。
<?PHP
store data
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$user_ip=$_SERVER['REMOTE_ADDR'];
//Redirect to google
header("Location: http://www.google.com");
//Erase the output buffer
ob_end_clean();
//Tell the browser that the connection's closed
header("Connection: close");
//Ignore the user's abort (which we caused with the redirect).
ignore_user_abort(true);
//Extend time limit to 30 minutes
set_time_limit(1800);
//Extend memory limit to 10MB
ini_set("memory_limit","10M");
//Start output buffering again
ob_start();
//Tell the browser we're serious... there's really
//nothing else to receive from this page.
header("Content-Length: 0");
//Send the output buffer and turn output buffering off.
ob_end_flush();
//Yes... flush again.
flush();
//Close the session.
session_write_close();
//After redirection no need to send any data to user anymore.
//User would It's seem that user need to wait till script is finish before browser can be direct.
//Do some work
//sleep(10);
$matched = $wurflObj->getDeviceCapabilitiesFromAgent($userAgent);
$org = geoip_org_by_name($user_ip);
?>