PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / api / Cookie / Cookie.php

Cookie.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at api/Cookie/Cookie.php

43 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\Api\Cookie;
4
5 class Cookie
6 {
7 private static string $key = 'fct_cart_hash';
8
9 public static function getCartHash(string $default = ''): string
10 {
11 $hash = \FluentCart\Framework\Http\Cookie::get(static::getCartHashKey(), $default);
12 return trim($hash);
13 }
14
15 public static function getCartHashKey(): string
16 {
17 return self::$key;
18 }
19
20 public static function setCartHash(string $cartHash): void
21 {
22 $expireTime = apply_filters('fluent_cart/cart_cookie_minutes', time() + 24 * 60 * 30);
23 setcookie(static::getCartHashKey(), $cartHash, [
24 'expires' => $expireTime,
25 'path' => COOKIEPATH,
26 'domain' => COOKIE_DOMAIN,
27 'secure' => is_ssl(),
28 'httponly' => false,
29 'samesite' => 'Lax',
30 ]);
31 }
32
33 public static function deleteCartHash(): void
34 {
35 \FluentCart\Framework\Http\Cookie::delete(
36 static::getCartHashKey(),
37 COOKIEPATH,
38 COOKIE_DOMAIN
39 );
40 //setcookie(static::getCartHashKey(), false, time() - 1000, COOKIEPATH, COOKIE_DOMAIN);
41 }
42 }
43