I'm having a issue where chrome mobile will load the page once, and the load the page again a second later. This is only visible in the server logs. This wouldn't be a problem normally, however I'm using the loaded page to +1 to a MySQL database via a query. So when someone on mobile with chrome visits the page instead of +1 I get +2. Which is problematic.
Server logs:
141.101.98.206 - - [28/Sep/2015:16:18:12 +0100] "GET /vfm-admin/vfm-downloader.php?q=***=&h=***&sh=***&t=***&n=***HTTP/1.1" 200 483 "https://new.***.net/?dl=***" "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LMY48P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2519.0 Mobile Safari/537.36"
141.101.98.206 - - [28/Sep/2015:16:18:13 +0100] "GET /vfm-admin/vfm-downloader.php?q=***=&h=***&sh=***&t=***&n=***HTTP/1.1" 200 144 "https://new.***.net/?dl=***" "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LMY48P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2519.0 Mobile Safari/537.36"
I found this online: https://code.google.com/p/chromium/issues/detail?id=64810 but after implementing everything suggested there the issues still persists, but only on mobile.
I tried to hack my way around the issue by using sessions, but since the script also serves a file to download it just downloads the if session error message as a file, see:
if(isset($_SESSION['user']))
{
echo "Session error, if issue persists please clear your cache</br>";
echo "<a href=\"javascript:history.go(-1)\">Back to download</a></br>";
exit();
}
else
{
//download function
}
Update 1:
As per suggestions I replaced the error echo with the download headers, this works fine on mobile. However if the if statement is then tripped on desktop it endlessly loads with no errors on either end.
if(isset($_SESSION['user']))
{
$headers = $downloader->getHeaders($getfile);
$downloader->aDownload(
$headers['file'],
$headers['filename'],
$headers['file_size']
);
exit();
}
else
{
// download function
}