Am baffled by a simple code even as experienced developer. Am trying to redirect a user depending on two condition. I have a variable called $isMobile which is boolean. Now below code cannot work if i add redirect but removing redirect header, it works
This does not work
if($isMobile){
header('Location:http://localhost/myproject/mobile/login/');
exit();
}
else{
header('Location:http://localhost/myproject/pc/login/');
exit();
}
//Error: too many redirects as if both conditions are true. Weird right?
This works
if($isMobile){
echo 'redirect to mobile folder';
}
else{
echo 'redirect to desktop folder';
}
What makes everything stop after adding both header redirects? I need to redirect users depending on their devices. Am so stuck here guys.
Aucun commentaire:
Enregistrer un commentaire