Skip to content

Commit

Permalink
Don't save a null value with setcookie() (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
darcythomas committed Jun 2, 2023
1 parent f2943cc commit f4fbbc3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Raygun4php/RaygunClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ private function StoreOrRetrieveUserCookie($key, $value)
{
if (is_string($value)) {
if (php_sapi_name() != 'cli' && !headers_sent()) {
$this->setCookie($key, $value);
$this->setCookie($key, $value ?? '');
}

return $value;
} else {
if (array_key_exists($key, $_COOKIE)) {
if ($_COOKIE[$key] != $value && php_sapi_name() != 'cli' && !headers_sent()) {
$this->setCookie($key, $value);
$this->setCookie($key, $value ?? '');
}
return $_COOKIE[$key];
}
Expand Down

0 comments on commit f4fbbc3

Please sign in to comment.