Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions code/MobileBrowserDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ public static function is_win_phone() {
* @return bool
*/
public static function is_mobile($agent = null) {
//return true;
$isMobile = false;
if (isset($_GET['flush']))
Session::clear('isMobile'); //makes sure session cache is cleared when flush is requested
$isMobile=Session::get('isMobile');
if (!$isMobile&&$isMobile!==0){
if(!$agent) $agent = $_SERVER['HTTP_USER_AGENT'];
$accept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : '';
$accept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : '';

switch(true) {
case(self::is_iphone()):
Expand Down Expand Up @@ -101,11 +106,14 @@ public static function is_mobile($agent = null) {
$isMobile = true;
break;
}

if (!$isMobile) $isMobile=0;
Session::set('isMobile', $isMobile);
}
if(!headers_sent()) {
header('Cache-Control: no-transform');
header('Vary: User-Agent, Accept');
}


return $isMobile;
}
Expand Down