Hi. I am trying to redirect my visitors to for example http://localhost/site/test.php?lang=en_US
based on the country code in the cookie like this:
if (isset($_COOKIE['country']))
{
$country = $_COOKIE['country'];
header('Location: test.php?lang=en_US');
if ($country == "NO"){
header('Location: test.php?lang=no_NO');
}
}
else
{
header('Location: test.php?lang=en_US');
}
But i get this weird error in firefox: The page isn't redirecting properly
Found a solution:
if (!isset($_GET['lang']))
{
if (isset($_COOKIE['country']))
{
$country = $_COOKIE['country'];
$redirect = "en_US";
if ($country == "NO"){
$redirect = "no_NO";
header('Location: crime.php?lang='.$redirect);
}
if ($country == "EN"){
$redirect = "en_US";
header('Location: crime.php?lang='.$redirect);
}
}
else
{
header('Location: crime.php?lang=en_US');
}
}