Hey guys. So I have a mobile version of my website but i need to redirect the user to mobile version if they are using a mobile to browse my website. I added the code in index.php like this:
if(isMobile() == true) {
// if the function returned true, it's a mobile.
//echo "mobile"; // delete this line in your code, and uncomment the next line
header('Location: *************************'); // let's redirect the page to the mobile site
}
It works great. But when it detects that the user is using a mobile to access the site.. it redirects the user to the url but the browser gives me an error that there is too many redirect loops.
So my soultion to fix the problem is to see if the current template is the mobile template, if it is, then it won't redirect the user to the same url over and over again and thus giving that error.
so it would be somthing like:
if(isMobile() == true && isset($_SESSION['current_template']) != mobile) {
// if the function returned true, it's a mobile.
//echo "mobile"; // delete this line in your code, and uncomment the next line
header('Location: ******************************'); // let's redirect the page to the mobile site
}
So i really need the real code in red. Please help. I would really appreciate it.