Reputation: 1
On my desktop site, I'm using a redirect script "detectmobilebrowser.js" (from detectmobilebrowsers.com) that's working great to redirect mobile users to my mobile site. This code is loaded in the header.php file.
On my mobile site i have a link pointing back to my Desktop site with a URL Parameter 'nomobile'. on the desktop site i have the following code (below) that detects the url parameter and does nothing if it exists, or redirects to the mobile site using the .js detection file if the parameter doesn't exist.
My problem is once a user clicks on any link from the home page, i lose the url parameter and the mobile user is redirected back to the mobile site. How can I keep the mobile user on the desktop site without changing hundreds of links on my page to include the url parameter?
<?php
if(isset($_GET['nomobile'])){
echo "";
} else {
echo "<script src='http://mywebsite.com/detectmobilebrowser.js'></script>";
}
?>
Upvotes: 0
Views: 336
Reputation: 2903
Don't use a URL parameter to set. Try using a session variable instead.
To set the session variable
$_SESSION['nomobile']=true;
To check if the session is set
if(isset($_SESSION['nomobile'])) {
// do stuff
}
Alternatively, you could also use cookies instead of session variables, and that should produce the same results.
Upvotes: 0