简体   繁体   中英

Mobile Redirect Getting back to desktop site

I have added a php mobile redirect to my site:

<?php


require_once('mobile_device_detect.php');
$mobile = mobile_device_detect();
if($mobile==true){
  header('Location:http://www.esielectrical.co.uk/mobile');
}else{
  header('Location:http://www.esielectrical.co.uk/index.html');
}
exit;

?>

When I'm using the mobile site, I'm trying to get back to the desktop version using a link.

What is the best way of doing this?

Can someone help me out?

Thanks in advance!

The link should probably have a URL variable on it so you can add to your mobile check to see if that variable is set. Once that variable is set you can set a value in session and use that to check the users current preference to mobile or desktop.

When Server gets a page request at that this request header also have browser info. As because this is request.

When you set header from server at that you are sending the response. Note that you are sending response and at this time you should set parameter for showing mobile version for the page where you are redirecting so that the page where you are redirecting can detect that for this redirect i need to show mobile version.

You can set cookies, you should set this cookie when first time you get the request form end user. U can store Operating System type in cookie.

or pass values in url so detecting it render mobile version.

Your problem should be in between this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM