1: <?php
2: namespace codemania\core;
3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13: defined('CM_ROOT') or exit('Заперт доступа!');
14:
15: class Cookie {
16: static public $_salt = false;
17: static public $_path = '/';
18: static public $_domain;
19: static public $_secure = false;
20: static public $_httponly = false;
21: static public function get($name) {
22: if (isset($_COOKIE[(string)$name])) {
23: return base_64_decode($_COOKIE[$name]);
24: }
25: return false;
26: }
27: static public function set($name, $value, $expire) {
28: $value = base_64_encode($value);
29: setcookie((string)$name, (string)$value, time() + (int)$expire,
30: self::$_path, self::$_domain, self::$_secure, self::$_httponly);
31: }
32: static public function delete($name) {
33: if (isset($_COOKIE[(string)$name])) {
34: unset($_COOKIE[$name]);
35: setcookie($name, null, time() - 3600,
36: self::$_path, self::$_domain, self::$_secure, self::$_httponly);
37: return true;
38: }
39: return false;
40: }
41: }