]> _ Git - cubist_cms-back.git/commitdiff
wip #5851
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Sat, 8 Apr 2023 10:55:00 +0000 (12:55 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Sat, 8 Apr 2023 10:55:00 +0000 (12:55 +0200)
src/app/CookieServiceProvider.php
src/app/Magic/CubistMagicAttribute.php

index f35d55405e6fc820920d8ee146585c568f494f69..1ecb6890358445888901ac2c59fa3999ac17e3ca 100644 (file)
@@ -10,13 +10,12 @@ class CookieServiceProvider extends Base
     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;
@@ -29,6 +28,10 @@ class CookieServiceProvider extends Base
                     $domain = $found;
                 }
             }
+
+            if (!isset($domain)) {
+                $domain = count($domains) > 0 ? $domains[0] : null;
+            }
             config(['session.domain' => $domain]);
 
             return (new CookieJar)->setDefaultPathAndDomain(
index 31d92a6e36aecb87d98e428a7bf7cb36c89db169..66423c3c0ddb0be0d4d1ac6f34bb452f30a9e121 100644 (file)
@@ -57,7 +57,7 @@ trait CubistMagicAttribute
         return [];
     }
 
-    public function offsetSet($offset, $value)
+    public function offsetSet($offset, $value): void
     {
         if (is_null($offset)) {
 
@@ -66,17 +66,17 @@ trait CubistMagicAttribute
         }
     }
 
-    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);
     }