Change default Cookie path to "/" for compatibility with JS function setCookie()

This commit is contained in:
Kijin Sung 2023-10-24 23:17:01 +09:00
parent 8d2b7101f4
commit 80e50d41f5
5 changed files with 6 additions and 6 deletions

View file

@ -321,7 +321,7 @@ class Context
$lang_type = preg_replace('/[^a-zA-Z0-9_-]/', '', $lang_type ?? ''); $lang_type = preg_replace('/[^a-zA-Z0-9_-]/', '', $lang_type ?? '');
if ($set_lang_cookie) if ($set_lang_cookie)
{ {
Rhymix\Framework\Cookie::set('lang_type', $lang_type, ['expires' => 365]); Rhymix\Framework\Cookie::set('lang_type', $lang_type, ['expires' => 365, 'path' => \RX_BASEURL]);
} }
if(!$lang_type || !isset($enabled_langs[$lang_type])) if(!$lang_type || !isset($enabled_langs[$lang_type]))

View file

@ -72,7 +72,7 @@ class Mobile
$uatype = $uahash . ':' . (self::$_ismobile ? '1' : '0'); $uatype = $uahash . ':' . (self::$_ismobile ? '1' : '0');
if ($cookie !== $uatype) if ($cookie !== $uatype)
{ {
Rhymix\Framework\Cookie::set('rx_uatype', $uatype, ['expires' => 0]); Rhymix\Framework\Cookie::set('rx_uatype', $uatype, ['expires' => 0, 'path' => \RX_BASEURL]);
} }
return self::$_ismobile; return self::$_ismobile;

View file

@ -60,7 +60,7 @@ class Cookie
// Set defaults. // Set defaults.
if (!array_key_exists('path', $options)) if (!array_key_exists('path', $options))
{ {
$options['path'] = config('cookie.path') ?? \RX_BASEURL; $options['path'] = config('cookie.path') ?? '/';
} }
if (!array_key_exists('domain', $options) && ($default_domain = config('cookie.domain'))) if (!array_key_exists('domain', $options) && ($default_domain = config('cookie.domain')))
{ {
@ -87,7 +87,7 @@ class Cookie
else else
{ {
$expires = $options['expires']; $expires = $options['expires'];
$path = $options['path'] ?? \RX_BASEURL; $path = $options['path'] ?? '/';
$domain = $options['domain'] ?? null; $domain = $options['domain'] ?? null;
$secure = $options['secure'] ?? false; $secure = $options['secure'] ?? false;
$httponly = $options['httponly'] ?? false; $httponly = $options['httponly'] ?? false;

View file

@ -470,7 +470,7 @@ class UA
{ {
if (in_array($color_scheme, ['light', 'dark'])) if (in_array($color_scheme, ['light', 'dark']))
{ {
Cookie::set('rx_color_scheme', $color_scheme, ['expires' => 365]); Cookie::set('rx_color_scheme', $color_scheme, ['expires' => 365, 'path' => \RX_BASEURL]);
} }
else else
{ {

View file

@ -1122,7 +1122,7 @@ class NcenterliteController extends Ncenterlite
} }
if(!empty($_COOKIE['_ncenterlite_hide_id'])) if(!empty($_COOKIE['_ncenterlite_hide_id']))
{ {
Rhymix\Framework\Cookie::remove('_ncenterlite_hide_id', ['path' => '/']); Rhymix\Framework\Cookie::remove('_ncenterlite_hide_id');
} }
$oMemberModel = getModel('member'); $oMemberModel = getModel('member');