microphp/Core/RequestCookie.php

28 lines
850 B
PHP
Executable File

<?php
include_once "Reflection.php";
class RequestCookie {
use ReflectionHook;
static $_attributes = [];
static $readyHeaders = false;
public function __construct()
{
if(!RequestCookie::$readyHeaders)
{
RequestCookie::$_attributes = (array) $_COOKIE;
};
}
public function setAttribute($name, $value, $time = '+1 years')
{
$formarly = strtolower($name);
setcookie($name, $value, strtotime( $time ));
}
public function getAttribute($name)
{
$formarly = strtolower($name);
return RequestCookie::$_attributes[$formarly];
}
public function removeAttribute($name)
{
$this->setAttribute($name, 0, "-1 days");
}
};