public function register()
{
$this->app->singleton('cookie', function ($app) {
- $config = $app->make('config')->get('session');
-
- $domains = explode(',', $config['domain']);
+ $config = config('session');
+ $domains = !is_null($config['domain']) ? explode(',', $config['domain']) : [];
if (count($domains) === 1) {
$domain = $domains[0];
- } else {
+ } else if (isset($_SERVER['HTTP_HOST'])) {
foreach ($domains as $domain) {
if (stripos($_SERVER['HTTP_HOST'], $domain) !== false) {
$found = $domain;
$domain = $found;
}
}
+
+ if (!isset($domain)) {
+ $domain = count($domains) > 0 ? $domains[0] : null;
+ }
config(['session.domain' => $domain]);
return (new CookieJar)->setDefaultPathAndDomain(
return [];
}
- public function offsetSet($offset, $value)
+ public function offsetSet($offset, $value): void
{
if (is_null($offset)) {
}
}
- public function offsetExists($offset)
+ public function offsetExists($offset): bool
{
return $this->hasAttribute($offset);
}
- public function offsetUnset($offset)
+ public function offsetUnset($offset): void
{
$this->unsetAttribute($offset);
}
- public function offsetGet($offset)
+ public function offsetGet($offset): mixed
{
return $this->getAttribute($offset, null);
}