Forum Moderators: coopster
I'm using an incoming URL with a special country code attached. If the code is defined and valid, the code is stripped off and set to a cookie, and then 301 redirected to the same page, but without the attached code.
Then, if the page loads without an attached code, the script looks for a country cookie. If there is a cookie found, it loads up one way based on that country. If no cookie is found, it loads up with the United States as default.
The problem is, I'm stuck in a loop. If no country code is defined, then the page loads up great. However, if a country code is defined, then it never stops.
Here's the relevant code:
*****
$iso=array("dz","ao");
if((isset($_REQUEST["c"]))&&(in_array(strtolower($_REQUEST["c"]),$iso))){
setcookie("c",strtolower($_REQUEST["c"]),time()+60,"/",".example.com");
header("HTTP/1.1 301 Moved Permanently");
header("Location:http://www.example.com/folder/");
}
elseif(isset($_COOKIE["c"])){
$c=$_COOKIE["c"];
if($c=="dz"){
$c=array("dz","Algeria","Algerian",1);
}
else{
$c=array("ao","Angola","Angolan",1);
}
}
else{
$c=array("us","United States","American",7);
}
*****
Incoming links would either look like this:
example.com/folder/
example.com/folder/?c=dz
example.com/folder/?c=ao
Thanks for any help