I have a WordPress website (abetterworldbydesign.com) which has user-agent detection to redirect mobile websites to a subdirectory. It is using the plugin: WPtap Mobile Detector
I want to include a toggle link to switch between the mobile and desktop version. How can I make the site remember that a mobile user has switched to the desktop version and avoid redirecting that user to the mobile version again?
A session will probably be the easiest, or still detect mobile, but have a ?mobile=false
attached the URL that prevents the user from being redirected, but allows them to easily get back to the mobile site.
Checking the HTTP_REFERRER is the easiest method - no cookies & just one check. If the referrer is on your domain - then don't redirect.