You are here

static function Helper::cookie__set in Anti Spam by CleanTalk 8.3

* Setting cookie

File

src/lib/Cleantalk/Common/Helper.php, line 686

Class

Helper
Cleantalk's hepler class

Namespace

Drupal\cleantalk\lib\Cleantalk\Common

Code

static function cookie__set($name, $value = '', $expires = 0, $path = '', $domain = null, $secure = false, $httponly = false, $samesite = null) {

  // For PHP 7.3+ and above
  if (version_compare(phpversion(), '7.3.0', '>=')) {
    $params = array(
      'expires' => $expires,
      'path' => $path,
      'domain' => $domain,
      'secure' => $secure,
      'httponly' => $httponly,
    );
    if ($samesite) {
      $params['samesite'] = $samesite;
    }
    setcookie($name, $value, $params);

    // For PHP 5.6 - 7.2
  }
  else {
    setcookie($name, $value, $expires, $path, $domain, $secure, $httponly);
  }
}