-1

I have done some digging out here and am still a little unsure how to accomplish this. Here is the scenario:

I have a full HTML site that calls the following PHP code:

<?php
    require_once('inc/mobile_device_detect.php');
    mobile_device_detect(true,true,true,true,true,true,true,'mobile/',false);
?>
<!DOCTYPE html>
<html lang="en">
<head>blah blah</head>
etc...

The mobile_device_detect.php is a small library from http://detectmobilebrowsers.mobi/

So when I go to the full site from my mobile phone, the redirect happens perfectly. Next, on the mobile/index.html I have the following redirect code for those users that are wanting to see the full site (I should also mention that this mobile site uses jquery-mobile):

<a href="../index.html" data-ajax="false" rel="external"><img src="images/icons/world.png" width="32" height="32" alt="Full Site" class="ui-li-icon">Full Site</a>

When I click this link, I am resent back to the mobile page. I know this is happening because the redirect script is being fired again. I have tested this by visiting the mobile site with a desktop client and the redirect occurs perfectly.

Any ideas how I can remedy this for mobile users wanting to see the 'full site'?

tmparisi
  • 111
  • 1
  • 5
  • 19

1 Answers1

1

You can append a query param on your href like href="../index.html?full=true" in your main page check that full param is not present.

<?php
    if (!isset($_GET['full'])) {
      require_once('inc/mobile_device_detect.php');
      mobile_device_detect(true,true,true,true,true,true,true,'mobile/',false);
    }
?>
dm03514
  • 54,664
  • 18
  • 108
  • 145
  • You could also set it in the session, too, and make it a session-wide choice. – ajm Jun 27 '12 at 16:34
  • I found that I could simply check the referring domain with: if (strpos($_SERVER[HTTP_REFERER],"domain-name.com")==0) { blah blah } – tmparisi Jun 27 '12 at 16:35