php - Redirect loop in full site to mobile site using session -


i have full site has been in os-commerce , mobile site in core php (codeignitor), , full version , mobile version on sub-domain.

e.g full site: www.example.com , mobile site domain m.example.com. when user open full site domain in mobile, website redirect proper mobile domain, if mobile user want view full site user can view fullsite in mobile.

i have used complete redirect http://code.google.com/p/php-mobile-detect/, not redirecting full site or mobile site using session. know have use php sessions , request in order work not sure how use them in instance, please suggest how solve redirecting issue using session?

here code is:

session_start();     include('includes/mobile_detect.php');   $detect = new mobile_detect;   if(isset($_request['fullsite']) && $_request['fullsite'] == 'yes')  {//check if fullsite view request mobile or website?      $_session['fullsite']="yes";      if($detect->ismobile()) {                $_session['website']="mobile";     }     else{        $_session['website']="computer";      }      $devicetype = header('location: https://www.example.com/');   }   else   {     if($_session['website'] =="mobile"  && $_session['fullsite'] !="yes")     {         if($detect->istablet())         {             $devicetype = 'tablet';         }         else         {             $devicetype = 'phone';         }          $devicetype = header('location: https://m.example.com/');     }     elseif($_session['website'] =="computer" && $_session['fullsite'] =="yes")     {         $devicetype = 'computer';         $devicetype = header('location: https://www.example.com/');     }     else{            $devicetype = 'computer';      }      $scriptversion = $detect->getscriptversion();     session_destroy();   } 

from github page should able make work this:

index.php

session_start();  if ($_get['fullscreen'] == 'yes') {     $_session['fullscreen'] = 1; } else if ($_get['fullscreen'] == 'no') {     $_session['fullscreen'] = 0; }  if (false == isset($_session['fullscreen']) && ($_session['fullscreen'] == 0)) {     // if session['fullscreen'] has not been set (maybe first visit     // or user not in fullscree     // check device , redirect     require_once 'mobile_detect.php';     $detect = new mobile_detect();       // mobile device (phones or tablets).     if ( $detect->ismobile() ) {      }     ... }  // other code here 

when visiting mobile, if user wants full version, provide anchor url parameter fullscreen=yes (http://example.com?fullscreen=yes) if on full site , detect mobile (not included in code above), provide link mobile version fullscreen=no


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -