Hi,
I am trying to get my website to detect the type of browser that a user uses when they come to my site and depending on whether its a mobile/tablet they would be redirected to my mobile friendly site.
Below is the code I have to go into my home page for the normal site, I dont know exactly where to place it (i.e. head, body)
[php]<?php error_reporting(E_ALL && ~E_NOTICE); session_start(); header(“Vary: User-Agent, Accept”);
require_once ‘Mobile_Detect.php’; $detect = new Mobile_Detect();
if(in_array($GET[‘layout’], array(‘mobile’, ‘desktop’))){
setcookie(‘layout’, null); setcookie(‘layout’, $GET[‘layout’], time()+60602430, ‘/’, ‘www.homesandinvestments.com’); $layout = $GET[‘layout’];
} else {
if(!$COOKIE[‘layout’]){
$layout = ($detect->isMobile() ? ($detect->isTablet() ? ‘tablet’ : ‘mobile’) : ‘desktop’); setcookie(‘layout’, $layout, time()+60602430, ‘/’, ‘.homesandinvestments.com’);
} else {
$layout = $COOKIE[‘layout’];
}
}
if ($detect->isMobile()) {
header(‘http://www.m.homesandinvestments.com’, true, 301);[/php]
Any advise is appreciated!
Thanks!!