mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
Don't trust mobile cookie if the user agent has changed
This commit is contained in:
parent
ad8a07096c
commit
c58c905a93
1 changed files with 2 additions and 1 deletions
|
|
@ -45,7 +45,7 @@ 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']) ? $_COOKIE['mobile'] : null;
|
||||
$cookie = (isset($_COOKIE['mobile']) && $_SESSION['user_agent'] === md5($_SERVER['HTTP_USER_AGENT'])) ? $_COOKIE['mobile'] : null;
|
||||
if ($m === '1' || $cookie === 'true')
|
||||
{
|
||||
self::$_ismobile = TRUE;
|
||||
|
|
@ -62,6 +62,7 @@ class Mobile
|
|||
// Set cookie to prevent recalculation.
|
||||
if (!$cookie)
|
||||
{
|
||||
$_SESSION['user_agent'] = md5($_SERVER['HTTP_USER_AGENT']);
|
||||
$_COOKIE['mobile'] = self::$_ismobile ? 'true' : 'false';
|
||||
setcookie('mobile', $_COOKIE['mobile'], 0, RX_BASEURL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue