It’s handy for people who don’t know that you have a mobile version of your site, or know what the URL is (is it sitename.com/mobile? Is it mobile.sitename.com? Is it something else?) On the other hand people often want to view the full version of a site on their mobile device. You can achieve this quite simply.
This code goes at the top of your header include file, or at least at the top of each page you wish to redirect. It must go before any page rendering happens, or you will get the dreaded “headers have already been sent” error.
In the header of the mobile site add some code to reset the override cookie to allow the mobile site to be seen. The assumption is that you view the mobile site until you tell the application otherwise:
All that is left to do is to give the manual option for switching between the two versions, in the form of links.
From mobile to full (includes variable to set view mobile to false):
<a href="http://yoursite.com/index.php?mv=0">View Full Website</a>
And the option to return to the mobile version, where the cookie is automatically changed just by visiting:
<a href="http://yoursite.com/mobile/">View Mobile Website</a>