How to allow visitors click on "Desktop View" when htaccess send them in mobile view?
When people visit my domain.com th开发者_Python百科ey are redirected with htaccess to domain.com/m that is the mobile version. However, I want to have a "return to desktop view" also.
My question is how can I do it, if the htaccess send me back to the mobile version ?
I would say that one simple way to do this would be to make a php session variable that is set when the user first opts into the desktop version of the site.
When the user clicks the 'return to desktop view link', execute a function like this one:
function force_desktop_mode () {
if (!isset($_SESSION['desktop'])) {
$_SESSION['desktop'] = true;
}
}
Then, at the beginning of the page (in mobile view, when user is freshly redirected to mobile site)
if ($_SESSTION['desktop']) {
// redirect to nonmobile version of the site
}
check the php manual for some additional examples on how to use session variables.
精彩评论