OpenSencillo  2016.106
Long live the simplicity of PHP
 All Data Structures Namespaces Files Functions Pages
cookies.manager.cksman.php
1 <?php
2 /*~ cookies.php
3 .---------------------------------------------------------------------------.
4 | Software: Sencillo Cookies |
5 | Version: 2015.003 |
6 | Contact: ph@mastery.sk |
7 | ------------------------------------------------------------------------- |
8 | Author: Bc. Peter Horváth (original founder) |
9 | Copyright (c) 2015, Bc. Peter Horváth. All Rights Reserved. |
10 | ------------------------------------------------------------------------- |
11 | License: Distributed under the General Public License (GPL) |
12 | http://www.gnu.org/licenses/gpl-3.0.html |
13 | This program is distributed in the hope that it will be useful - WITHOUT |
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
15 | FITNESS FOR A PARTICULAR PURPOSE. |
16 '---------------------------------------------------------------------------'
17 ~*/
28 {
29  private $name;
30  private $expiration;
31  private $data;
32 
36  public function __construct()
37  {
38  $this->expiration = time()+3600;
39  }
40 
45  public function setExpiration($time)
46  {
47  $this->expiration = time()+($time*60);
48  }
49 
55  public function addCookie($name,$data)
56  {
57  $this->name = $name;
58 
59  $this->data = $data;
60  setcookie($this->name,$this->data,$this->expiration);
61  }
62 
67  public function removeCookie($name)
68  {
69  $this->name = $name;
70 
71  setcookie($this->name,"",time()-3600);
72  }
73 
79  public function getCookie($name)
80  {
81  $this->name = $name;
82 
83  return $_COOKIE[$this->name];
84  }
85 }
86 ?>