开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜