hook_preprocess_page for mobile detection I am attempting to set a variable $is_mobile that I can use in my page.tpl.php function.

function mytheme_preprocess_page(&amp;$vars)
{
    require_once(libraries_get_path('mobile_detect').'/Mobile_Detect.php');
    $detect = new Mobile_Detect();
    $is_mobile = $detect-&gt;isMobile() or $detect-&gt;isTablet();
    $vars['is_mobile'] = $is_mobile;
}


It seems the result is cached and whatever the first hit will be used.

My overall goal is to create a dynamic menu for mobile and desktop. (One for each)

What is the best way to approach to this?
You could use panels and create a variant for mobile and other for non mobile.

the mobile detect module provide a selection rule for that by using 
mobile_detect_ctools