isset($argList[2]) === true ? $argList[2] : 0, 'path' => isset($argList[3]) === true ? $argList[3] : '', 'domain' => isset($argList[4]) === true ? $argList[4] : '', 'secure' => isset($argList[5]) === true ? $argList[5] : false, 'httponly' => isset($argList[6]) === true ? $argList[6] : false, ); } if (!headers_sent()) { // set the cookie if (version_compare(PHP_VERSION, '7.3', '>=')) { setcookie($name, $value, $options); } else { // using the setcookie function before php 7.3, make sure we have default values if (array_key_exists('expires', $options) === false) { $options['expires'] = 0; } if (array_key_exists('path', $options) === false) { $options['path'] = ''; } if (array_key_exists('domain', $options) === false) { $options['domain'] = ''; } if (array_key_exists('secure', $options) === false) { $options['secure'] = false; } if (array_key_exists('httponly', $options) === false) { $options['httponly'] = false; } setcookie($name, $value, $options['expires'], $options['path'], $options['domain'], $options['secure'], $options['httponly']); } } else { // headers already sent, register cookie via javascript $js = 'document.cookie="' . $name . '=' . $value . (!empty($options['expires']) ? '; expires=' . date('r', $expire) : '') . (!empty($options['path']) ? '; path=' . $path : '') . (!empty($options['samesite']) ? '; SameSite=' . $options['samesite'] : '') . (!empty($options['secure']) ? '; Secure' : ''); // register script JFactory::getDocument()->addScriptDeclaration($js); } $this->data[$name] = $value; } }