Php 移动重定向,然后想要返回到桌面版本并停留在那里。
我正在开发一个网站,其中有一个手机对应。我在页面顶部有一些代码,可以检测是否移动,并相应地使用php header命令重定向。我现在正在考虑在移动站点上添加一个“切换到桌面版本”的选项,但之后将其保留在桌面上 我猜我需要创建一个名为“mobile”的会话变量,但我不太清楚应该把它放在哪里 任何建议都会令人惊讶。以下是每页的代码。我不认为mobile_detect.php是冗长的,但可以在 试一试Php 移动重定向,然后想要返回到桌面版本并停留在那里。,php,redirect,mobile,desktop,Php,Redirect,Mobile,Desktop,我正在开发一个网站,其中有一个手机对应。我在页面顶部有一些代码,可以检测是否移动,并相应地使用php header命令重定向。我现在正在考虑在移动站点上添加一个“切换到桌面版本”的选项,但之后将其保留在桌面上 我猜我需要创建一个名为“mobile”的会话变量,但我不太清楚应该把它放在哪里 任何建议都会令人惊讶。以下是每页的代码。我不认为mobile_detect.php是冗长的,但可以在 试一试 <?php require_once('functions/Mobile_Detect.php
<?php require_once('functions/Mobile_Detect.php');
$detect = new Mobile_Detect();
// Exclude tablets.
if( $detect->isMobile() && !$detect->isTablet() ){
header("location:mobile/index.php");
}
?>
if ( !isset($_SESSION['forceDesktop']) )
$_SESSION['forceDesktop'] = false;
$detect = new Mobile_Detect();
// Exclude tablets.
if( $detect->isMobile() && !$detect->isTablet() && !$_SESSION['forceDesktop'] ){
header("location:mobile/index.php");
}
....
// some logic asking whether to force the desktop version
....
$_SESSION['forceDesktop'] = true;