Skip to content

Commit 784d8c9

Browse files
committed
fix: Session Handlers does not take Config\Cookie
1 parent 55a6861 commit 784d8c9

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

system/Session/Handlers/BaseHandler.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\Session\Handlers;
1313

1414
use Config\App as AppConfig;
15+
use Config\Cookie as CookieConfig;
1516
use Psr\Log\LoggerAwareTrait;
1617
use SessionHandlerInterface;
1718

@@ -102,14 +103,27 @@ abstract class BaseHandler implements SessionHandlerInterface
102103

103104
public function __construct(AppConfig $config, string $ipAddress)
104105
{
105-
$this->cookiePrefix = $config->cookiePrefix;
106-
$this->cookieDomain = $config->cookieDomain;
107-
$this->cookiePath = $config->cookiePath;
108-
$this->cookieSecure = $config->cookieSecure;
109-
$this->cookieName = $config->sessionCookieName;
110-
$this->matchIP = $config->sessionMatchIP;
111-
$this->savePath = $config->sessionSavePath;
112-
$this->ipAddress = $ipAddress;
106+
/** @var CookieConfig|null $cookie */
107+
$cookie = config('Cookie');
108+
109+
if ($cookie instanceof CookieConfig) {
110+
$this->cookiePrefix = $cookie->prefix;
111+
$this->cookieDomain = $cookie->domain;
112+
$this->cookiePath = $cookie->path;
113+
$this->cookieSecure = $cookie->secure;
114+
} else {
115+
// @TODO Remove this fallback when deprecated `App` members are removed.
116+
// `Config/Cookie.php` is absence
117+
$this->cookiePrefix = $config->cookiePrefix;
118+
$this->cookieDomain = $config->cookieDomain;
119+
$this->cookiePath = $config->cookiePath;
120+
$this->cookieSecure = $config->cookieSecure;
121+
}
122+
123+
$this->cookieName = $config->sessionCookieName;
124+
$this->matchIP = $config->sessionMatchIP;
125+
$this->savePath = $config->sessionSavePath;
126+
$this->ipAddress = $ipAddress;
113127
}
114128

115129
/**

0 commit comments

Comments
 (0)