1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace KIF;
- use KIF\Core\Request;
- use KIF\String\Filter;
- class Cookie {
-
- static public function get($key, $filters = array(Filter::HTMLSPECIALCHARS, Filter::TRIM)) {
- return Request::c($key, $filters);
- }
-
- static public function set($key, $value, $expiration = 0, $cookie_domain = null, $cookie_path = '/', $secure = false, $httponly = false) {
- if (is_null($cookie_domain)) {
- if (defined('DOMAIN')) {
- $cookie_domain = DOMAIN;
- } else {
- $cookie_domain = Request::rootDomain();
- }
- }
- if (is_null($cookie_path)) {
- $cookie_path = '/';
- }
- if (is_null($secure)) {
- $secure = false;
- }
- if (is_null($httponly)) {
- $httponly = false;
- }
-
- if ($expiration > 0 && $expiration <= 60*60*24*30) {
- $expiration += time();
- }
-
- $_COOKIE[$key] = $value;
- return setcookie($key, $value, $expiration, $cookie_path, $cookie_domain, $secure, $httponly);
- }
- }
|