You are here

Cookie.php in Anti Spam by CleanTalk 9.1.x

Same filename and directory in other branches
  1. 8.4 src/lib/Cleantalk/Common/Variables/Cookie.php

File

src/lib/Cleantalk/Common/Variables/Cookie.php
View source
<?php

namespace Cleantalk\Common\Variables;


/**
 * Class Cookie
 * Safety handler for $_COOKIE
 *
 * @since 3.0
 * @package Cleantalk\Variables
 */
class Cookie extends SuperGlobalVariables {
  static $instance;

  /**
   * Gets given $_COOKIE variable and save it to memory
   * @param $name
   *
   * @return mixed|string
   */
  protected function get_variable($name, $do_decode = true) {

    // Return from memory. From $this->variables
    if (isset(static::$instance->variables[$name])) {
      return static::$instance->variables[$name];
    }
    if (function_exists('filter_input')) {
      $value = filter_input(INPUT_COOKIE, $name);
    }
    if (empty($value)) {
      $value = isset($_COOKIE[$name]) ? $_COOKIE[$name] : '';
    }
    $value = $do_decode ? urldecode($value) : $value;
    return $value;
  }

}

Classes

Namesort descending Description
Cookie Class Cookie Safety handler for $_COOKIE