2022-01-05 18:11:00 -05:00
|
|
|
<?php
|
2022-01-30 18:02:52 -05:00
|
|
|
namespace App\Helpers;
|
2022-01-05 18:11:00 -05:00
|
|
|
|
2022-01-30 18:02:52 -05:00
|
|
|
class Cookies {
|
2022-02-20 10:25:15 -05:00
|
|
|
const PROXY = ['host', 'port', 'user', 'password'];
|
2022-01-05 18:11:00 -05:00
|
|
|
|
2022-02-20 10:25:15 -05:00
|
|
|
static public function get(string $name): ?string {
|
2022-01-05 18:11:00 -05:00
|
|
|
if (isset($_COOKIE[$name]) && !empty($_COOKIE[$name])) {
|
|
|
|
return $_COOKIE[$name];
|
|
|
|
}
|
2022-02-20 10:25:15 -05:00
|
|
|
return null;
|
2022-01-05 18:11:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function exists(string $name): bool {
|
|
|
|
return isset($_COOKIE[$name]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static public function set(string $name, string $value) {
|
2022-01-28 09:54:09 -05:00
|
|
|
setcookie($name, $value, time()+60*60*24*30, '/', '', isset($_SERVER['HTTPS']), true);
|
2022-01-05 18:11:00 -05:00
|
|
|
}
|
|
|
|
};
|