diff --git a/src/Authentication/AuthenticationBase.php b/src/Authentication/AuthenticationBase.php index bc44e59..ba7539d 100644 --- a/src/Authentication/AuthenticationBase.php +++ b/src/Authentication/AuthenticationBase.php @@ -2,6 +2,7 @@ namespace Myth\Auth\Authentication; +use CodeIgniter\CodeIgniter; use CodeIgniter\Events\Events; use CodeIgniter\Model; use Exception; @@ -222,6 +223,16 @@ public function rememberUser(int $userID) $appConfig = config('App'); $response = service('response'); + // Replace cookie config values from cookie.php file on new versions of CI (v4.4.0 and above) for BC. + if (version_compare(CodeIgniter::CI_VERSION, '4.3.8', '>')) { + $cookieConfig = config('Cookie'); + $appConfig->cookieDomain = $cookieConfig->domain; + $appConfig->cookiePath = $cookieConfig->path; + $appConfig->cookiePrefix = $cookieConfig->prefix; + $appConfig->cookieSecure = $cookieConfig->secure; + $appConfig->cookieHTTPOnly = $cookieConfig->httponly; + } + // Create the cookie $response->setCookie( 'remember', // Cookie Name @@ -259,6 +270,16 @@ public function refreshRemember(int $userID, string $selector) $appConfig = config('App'); + // Replace cookie config values from cookie.php file on new versions of CI (v4.4.0 and above) for BC. + if (version_compare(CodeIgniter::CI_VERSION, '4.3.8', '>')) { + $cookieConfig = config('Cookie'); + $appConfig->cookieDomain = $cookieConfig->domain; + $appConfig->cookiePath = $cookieConfig->path; + $appConfig->cookiePrefix = $cookieConfig->prefix; + $appConfig->cookieSecure = $cookieConfig->secure; + $appConfig->cookieHTTPOnly = $cookieConfig->httponly; + } + // Create the cookie set_cookie( 'remember', // Cookie Name