PHP 8.2.31
Preview: Cookies.php Size: 1.26 KB
/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/Util/Cookies.php

<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing

namespace MailPoet\Util;

if (!defined('ABSPATH')) exit;


use InvalidArgumentException;

class Cookies {
  const DEFAULT_OPTIONS = [
    'expires' => 0,
    'path' => '',
    'domain' => '',
    'secure' => false,
    'httponly' => false,
  ];

  public function set($name, $value, array $options = []) {
    $options = $options + self::DEFAULT_OPTIONS;
    $value = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
    $error = json_last_error();
    if ($error || ($value === false)) {
      throw new InvalidArgumentException();
    }

    // on PHP_VERSION_ID >= 70300 we'll be able to simply setcookie($name, $value, $options);
    setcookie(
      $name,
      $value,
      $options['expires'],
      $options['path'],
      $options['domain'],
      $options['secure'],
      $options['httponly']
    );
  }

  public function get($name) {
    if (!array_key_exists($name, $_COOKIE)) {
      return null;
    }
    $value = json_decode(sanitize_text_field(wp_unslash(($_COOKIE[$name]))), true);
    $error = json_last_error();
    if ($error) {
      return null;
    }
    return $value;
  }

  public function delete($name) {
    unset($_COOKIE[$name]);
  }
}

Directory Contents

Dirs: 3 × Files: 17

Name Size Perms Modified Actions
License DIR
- drwxr-xr-x 2023-04-04 05:35:40
Edit Download
Notices DIR
- drwxr-xr-x 2023-04-04 05:35:40
Edit Download
pQuery DIR
- drwxr-xr-x 2023-04-04 05:35:40
Edit Download
1.26 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
576 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
7.81 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.26 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
3.34 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.76 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.67 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.52 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
3.14 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
3.14 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
0 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
997 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
2.33 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
325 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
356 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
2.81 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.74 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).