You are here

public static function CleantalkFuncs::apbct_setcookie in Anti Spam by CleanTalk 8.4

Same name and namespace in other branches
  1. 8.3 src/CleantalkFuncs.php \Drupal\cleantalk\CleantalkFuncs::apbct_setcookie()
  2. 9.1.x src/CleantalkFuncs.php \Drupal\cleantalk\CleantalkFuncs::apbct_setcookie()

Save our variables into cookies OR sessions

Parameters

$name string Name of our variables to save:

$value string Value of our variables to save:

6 calls to CleantalkFuncs::apbct_setcookie()
AntiCrawler::check in src/lib/Cleantalk/Common/Firewall/Modules/AntiCrawler.php
Use this method to execute main logic of the module.
AntiFlood::check in src/lib/Cleantalk/Common/Firewall/Modules/AntiFlood.php
Use this method to execute main logic of the module.
BootSubscriber::handle in src/EventSubscriber/BootSubscriber.php
Handles a Request to convert it to a Response.
SetAltCookiesController::setCookies in src/Controller/SetAltCookiesController.php
SFW::actionsForPassed in src/lib/Cleantalk/Common/Firewall/Modules/SFW.php
@inheritdoc

... See full list

File

src/CleantalkFuncs.php, line 75

Class

CleantalkFuncs
Cleantalk class create request

Namespace

Drupal\cleantalk

Code

public static function apbct_setcookie($name, $value) {
  if (\Drupal::config('cleantalk.settings')
    ->get('cleantalk_set_cookies')) {
    if (\Drupal::config('cleantalk.settings')
      ->get('cleantalk_alternative_cookies_session')) {
      self::_apbct_alt_sessions__remove_old();

      // Into database
      $connection = \Drupal::database();
      $connection
        ->query("INSERT INTO {cleantalk_sessions}\n        (id, name, value, last_update)\n        VALUES (:id, :name, :value, :last_update)\n        ON DUPLICATE KEY UPDATE\n        value = :value,\n        last_update = :last_update", array(
        ':id' => self::_apbct_alt_session__id__get(),
        ':name' => $name,
        ':value' => $value,
        ':last_update' => date('Y-m-d H:i:s'),
      ));
    }
    else {

      // Into cookies
      setcookie($name, $value, 0, '/');
    }
  }
}