Home > Technical & Creative Skills > Programming, Servers & Scripts

Using cookes on mobile traffic (5)


05-10-2019 07:16 PM #1 sweepluso (Member)
Using cookes on mobile traffic

Hi guys,

Anyone can help me set up a script that checks/places a cookie on a mobile visitor?

So what i want is if a user has cookie XX is redirected to page B, if doesn't have the cookie it's redirect to page A and cookie is place.

This way i would eventually remove duplicated visits.

Thanks!


05-10-2019 07:27 PM #2 twinaxe (Senior Moderator)

What tracker do you use?
In Binom you can setup a rule IF user IS NOT unique THEN redirect to xyz.com

So when user already got tracked = has cookie you send him somewhere else.

Apart from that I can send you a PHP code for it when I am back on my PC.


05-11-2019 08:38 AM #3 sweepluso (Member)

Hey! thanks! I already use Voluum. If you could send me that code it would be great and i would test it!


05-11-2019 11:07 AM #4 twinaxe (Senior Moderator)

Here is a very simple PHP code for it

Code:
<?php
	if(isset($_COOKIE['yourcookie'])){
        header("Location: https://pageB.com"); 
        exit;
}
else{
	setcookie("yourcookie",9999999999);
        header("Location: https://pageA.com"); 
        exit;	
}
?>
It does exactly what you posted

if a user has cookie XX is redirected to page B, if doesn't have the cookie it's redirect to page A and cookie is place.
But I would do it little bit different.

Just put the code at the very beginning of page A.

Then it checks for the cookie.

When cookie exists the user gets redirected to page B.

When cookie doesn´t exist the cookie will be created and user stays on page A.

Code:
<?php
	if(isset($_COOKIE['yourcookie'])){
        header("Location: https://pageB.com"); 
        exit;
}
else{
	setcookie("yourcookie",9999999999);
}
?>
The 9999999999 is cookie duration in seconds, adjust it for your needs.


05-13-2019 12:41 PM #5 sweepluso (Member)

Cool! This looks simple... thanks!

can i add another else, to check if cookie is in place (if so move to my offer). I guess BOT won't allow cookies so might be good to cut "none cookie" traffic


Home > Technical & Creative Skills > Programming, Servers & Scripts