*/
public function createCookie(
$cookieName,
$value,
$expireTime = 0,
$path = '',
$domain = '',
$secure = false,
$httponly = false,
$samesite = 'Strict'
) {
global $domain_info;
if (!$cookieName || !$value) {
return false;
}
$options = [
'expires' => $expireTime,
'path' => $path ?: $domain_info['path'],
'domain' => $domain ?: $domain_info['domain'],
'secure' => $secure ?: $this->isHttps(),
'httponly' => $httponly,
'samesite' => $samesite,
];
/**
* @since 4.8.1 - 3rd parameter replaced to $options
* @since 4.7.0
*/
$GLOBALS['rlHook']->load('phpPreCreateCookie', $cookieName, $value, $options);
/*
* @todo - Remove when minimum PHP version will be 7.3
*/
if (PHP_VERSION_ID >= 70300) {
setcookie($cookieName, $value, $options);
} else {
$options['path'] = $options['path'] . "; samesite={$options['samesite']}";
setcookie(
$cookieName,
$value,
$options['expires'],
$options['path'],
$options['domain'],
$options['secure'],
$options['httponly']
);
}
return true;
}
/**