| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.7 Free | |
| 4 | + * @version 3.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | 8 | * @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| @@ -39,15 +39,8 @@ | ||
| 39 | 39 | */ |
| 40 | 40 | private $cookie_value = 1; |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * The path of the cookie. It should be available in the whole domain. | |
| 44 | - * | |
| 45 | - * @var string | |
| 46 | - */ | |
| 47 | - private $cookie_path = '/'; | |
| 48 | - | |
| 49 | - /** | |
| 50 | 43 | * Class constructor |
| 51 | 44 | * |
| 52 | 45 | * @param integer $box_id The box's ID |
| 53 | 46 | */ |
| @@ -63,9 +56,9 @@ | ||
| 63 | 56 | * @return string |
| 64 | 57 | */ |
| 65 | 58 | private function getName() |
| 66 | 59 | { |
| 67 | - return isset($this->box->ID) ? 'firebox_' . $this->box->ID : ''; | |
| 60 | + return isset($this->box->ID) ? \FireBox\Core\Helpers\BoxHelper::cookiePrefix() . $this->box->ID : ''; | |
| 68 | 61 | } |
| 69 | 62 | |
| 70 | 63 | /** |
| 71 | 64 | * Store cookie in the browser |
| @@ -73,8 +66,13 @@ | ||
| 73 | 66 | * @return void |
| 74 | 67 | */ |
| 75 | 68 | public function set() |
| 76 | 69 | { |
| 70 | + if (!is_object($this->box) || !isset($this->box->params)) | |
| 71 | + { | |
| 72 | + return; | |
| 73 | + } | |
| 74 | + | |
| 77 | 75 | $cookie_type = $this->box->params->get('assign_cookietype', 'days'); |
| 78 | 76 | |
| 79 | 77 | switch ($cookie_type) |
| 80 | 78 | { |
| @@ -95,9 +93,16 @@ | ||
| 95 | 93 | default: |
| 96 | 94 | $expire = 0; // session |
| 97 | 95 | } |
| 98 | 96 | |
| 99 | - $this->cookie->set($this->getName(), $this->cookie_value, $expire, $this->cookie_path, '', true); | |
| 97 | + $this->cookie->set( | |
| 98 | + $this->getName(), | |
| 99 | + $this->cookie_value, | |
| 100 | + $expire, | |
| 101 | + \FireBox\Core\Helpers\BoxHelper::cookiePath(), | |
| 102 | + \FireBox\Core\Helpers\BoxHelper::cookieDomain(), | |
| 103 | + true | |
| 104 | + ); | |
| 100 | 105 | } |
| 101 | 106 | |
| 102 | 107 | /** |
| 103 | 108 | * Check if the cookie of the box exist |
| @@ -115,7 +120,18 @@ | ||
| 115 | 120 | * @return void |
| 116 | 121 | */ |
| 117 | 122 | public function remove() |
| 118 | 123 | { |
| 119 | - $this->cookie->set($this->getName(), $this->cookie_value, strtotime('-1 day'), $this->cookie_path); | |
| 124 | + // Expire it on every path it may have been written to, or an older | |
| 125 | + // cookie at '/' would keep suppressing the campaign. | |
| 126 | + foreach (\FireBox\Core\Helpers\BoxHelper::cookiePathsToClear() as $path) | |
| 127 | + { | |
| 128 | + $this->cookie->set( | |
| 129 | + $this->getName(), | |
| 130 | + $this->cookie_value, | |
| 131 | + strtotime('-1 day'), | |
| 132 | + $path, | |
| 133 | + \FireBox\Core\Helpers\BoxHelper::cookieDomain() | |
| 134 | + ); | |
| 135 | + } | |
| 120 | 136 | } |
| 121 | 137 | } |