I need to redirect by cookie to another domain - multi-store
I have this code.
public function hookdisplayHeader()
{
$URL_P = $_SERVER['REQUEST_URI'];
$cookie = $this->context->cookie->forced_zone;
$dominiourl =$_SERVER['SERVER_NAME'];
if(!$cookie){
$cookie = 2;
$this->context->cookie->forced_zone = 2;
}
switch ($cookie) {
case '1':
if ($dominiourl != 'domain.1'){
header("Location: domain.1/".$URL_P);
}
case '2':
if ($dominiourl != 'domain.2'){
header("Location: domain.2/".$URL_P);
}
}
}
The problem I find is that it doesn't stop looping when trying to redirect.
Using IP works correctly.
Using forced redirection works correctly
Using cookie does not work