PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.31
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.31
2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 All 42 releases
fluent-boards / vendor / wpfluent / framework / src / WPFluent / Http / Cookie.php

Cookie.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.31, at vendor/wpfluent/framework/src/WPFluent/Http/Cookie.php

65 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\Framework\Http;
4
5 class Cookie
6 {
7 public static function set(
8 $name,
9 $value,
10 $minutes = 0,
11 $path = '',
12 $domain = '',
13 $secure = false,
14 $httponly = false
15 )
16 {
17 $time = ($minutes == 0) ? 0 : static::expiresAt($minutes * 60);
18
19 setcookie($name, $value, $time, $path, $domain, $secure, $httponly);
20 }
21
22 public static function setForever(
23 $name,
24 $value,
25 $path = '',
26 $domain = '',
27 $secure = false,
28 $httponly = false
29 )
30 {
31 $fiveYears = static::expiresAt((365 * 24 * 60 * 60) * 5);
32
33 setcookie($name, $value, $fiveYears, $path, $domain, $secure, $httponly);
34 }
35
36 public static function get($name, $default = null)
37 {
38 if (array_key_exists($name, $_COOKIE)) {
39 return $_COOKIE[$name];
40 }
41
42 return $default;
43 }
44
45 public static function delete($name, $path = '', $domain = '') {
46 setcookie($name, '', time() - 3600, $path, $domain);
47
48 if (array_key_exists($name, $_COOKIE)) {
49 unset($_COOKIE[$name]);
50 }
51 }
52
53 protected static function expiresAt($value = 0)
54 {
55 if (!$value instanceof \DateTimeInterface) {
56
57 $value = is_numeric($value) ? (int) $value : 0;
58
59 $value = new \DateTime('+' . $value . ' seconds');
60 }
61
62 return $value->getTimestamp();
63 }
64 }
65