Fix manual mobile setting not working

This commit is contained in:
Kijin Sung 2016-07-09 23:00:16 +09:00
parent ba8ff52904
commit 3d8b7755ee

View file

@ -46,11 +46,11 @@ class Mobile
// Try to detect from URL arguments and cookies, and finally fall back to user-agent detection.
$m = Context::get('m');
$cookie = (isset($_COOKIE['mobile']) && $_SESSION['user_agent'] === md5($_SERVER['HTTP_USER_AGENT'])) ? $_COOKIE['mobile'] : null;
if ($m === '1' || $cookie === 'true')
if ($m === '1' || ($m === null && $cookie === 'true'))
{
self::$_ismobile = TRUE;
}
elseif ($m === '0' || $cookie === 'false')
elseif ($m === '0' || ($m === null && $cookie === 'false'))
{
self::$_ismobile = FALSE;
}
@ -60,7 +60,7 @@ class Mobile
}
// Set cookie to prevent recalculation.
if (!$cookie)
if ($cookie !== (self::$_ismobile ? 'true' : 'false'))
{
$_SESSION['user_agent'] = md5($_SERVER['HTTP_USER_AGENT']);
$_COOKIE['mobile'] = self::$_ismobile ? 'true' : 'false';