mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +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.
|
// Try to detect from URL arguments and cookies, and finally fall back to user-agent detection.
|
||||||
$m = Context::get('m');
|
$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')
|
if ($m === '1' || $cookie === 'true')
|
||||||
{
|
{
|
||||||
self::$_ismobile = TRUE;
|
self::$_ismobile = TRUE;
|
||||||
|
|
@ -62,6 +62,7 @@ class Mobile
|
||||||
// Set cookie to prevent recalculation.
|
// Set cookie to prevent recalculation.
|
||||||
if (!$cookie)
|
if (!$cookie)
|
||||||
{
|
{
|
||||||
|
$_SESSION['user_agent'] = md5($_SERVER['HTTP_USER_AGENT']);
|
||||||
$_COOKIE['mobile'] = self::$_ismobile ? 'true' : 'false';
|
$_COOKIE['mobile'] = self::$_ismobile ? 'true' : 'false';
|
||||||
setcookie('mobile', $_COOKIE['mobile'], 0, RX_BASEURL);
|
setcookie('mobile', $_COOKIE['mobile'], 0, RX_BASEURL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue