Include this link:
<a href="#" onclick="goToDesktopVersion()">Switch to Desktop Version</a>
Below is the required javascript code (remember to follow the instructions in the comments):
function goToDesktopVersion(){
// 1.) Set a cookie to indicate preference for desktop version
// 2.) Redirect window.location to desktop version URL
}
Also, account for the cookie in your detection logic (implement code provided as comments):
function checkIfDeskopVersionCookieIsSet(){
// Check if the cookie exists and return true or false
}
...
var mobile = ...
if (mobile && !checkIfDeskopVersionCookieIsSet() ) {
document.location = "/mobile";
}
The cookie serves the purpose of preventing repeated redirection to the mobile version after selecting the "Switch to Desktop Version" link.
A cookie acts as a small piece of data stored on the user's browser to retain specific information. In this scenario, it signifies the user’s desire to view the desktop version of the site. Cookies facilitate data exchange between server and client, allowing storage on either end. Browser-based cookies can be created using Javascript. To simplify the process of setting a cookie, it is advisable to leverage existing cookie management code snippets.