Overview

Namespaces

  • codemania
    • core
      • exception
    • library
      • database
        • drivers
  • None
  • PHP

Classes

  • Cookie
  • Core
  • Crypt
  • HTTP
  • Request
  • Route
  • Security
  • Singleton
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
 1: <?php
 2: namespace codemania\core;
 3: /**
 4:  * CodeMania Framework
 5:  * 
 6:  * @author CodeMania Team <team@codemania.ru>
 7:  * @license http://codemania.ru/license.html
 8:  * @package CodeMania
 9:  * @version 1.0.0
10:  * @copyright (c) 2012, CodeMania Team
11:  * @link  http://codemania.ru/
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: }
CodeMania Framework API documentation generated by ApiGen 2.8.0