|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Manage Cookies |
|
5
|
|
|
* |
|
6
|
|
|
* @category lib |
|
7
|
|
|
* @author Judicaël Paquet <[email protected]> |
|
8
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
|
9
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
|
10
|
|
|
* @version Release: 1.0.0 |
|
11
|
|
|
* @filesource https://github.com/las93/venus2 |
|
12
|
|
|
* @link https://github.com/las93 |
|
13
|
|
|
* @since 1.0 |
|
14
|
|
|
*/ |
|
15
|
|
|
namespace Venus\lib; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* This class manage the Cookies |
|
19
|
|
|
* |
|
20
|
|
|
* @category lib |
|
21
|
|
|
* @author Judicaël Paquet <[email protected]> |
|
22
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
|
23
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
|
24
|
|
|
* @version Release: 1.0.0 |
|
25
|
|
|
* @filesource https://github.com/las93/venus2 |
|
26
|
|
|
* @link https://github.com/las93 |
|
27
|
|
|
* @since 1.0 |
|
28
|
|
|
*/ |
|
29
|
|
|
class Cookie |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* set a value |
|
33
|
|
|
* |
|
34
|
|
|
* @access public |
|
35
|
|
|
* @param string $sName name of the Cookie |
|
36
|
|
|
* @param mixed $mValue value of this sesion var |
|
37
|
|
|
* @return \Venus\lib\Cookie |
|
38
|
|
|
*/ |
|
39
|
|
|
public function set(string $sName, $mValue, int $iExpire = 0, string $sPath = '', string $sDomain = '', int $iSecure = false) : Cookie |
|
40
|
|
|
{ |
|
41
|
|
|
$iExpire = time() + $iExpire; |
|
42
|
|
|
setcookie($sName, $mValue, $iExpire, $sPath, $sDomain, $iSecure); |
|
43
|
|
|
return $this; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* set a value |
|
48
|
|
|
* |
|
49
|
|
|
* @access public |
|
50
|
|
|
* @param string $sName name of the Cookie |
|
51
|
|
|
* @return mixed |
|
52
|
|
|
*/ |
|
53
|
|
|
public function get(string $sName) |
|
54
|
|
|
{ |
|
55
|
|
|
return $_COOKIE[$sName]; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* set a value |
|
60
|
|
|
* |
|
61
|
|
|
* @access public |
|
62
|
|
|
* @param string $sName name of the Cookie |
|
63
|
|
|
* @return bool |
|
64
|
|
|
*/ |
|
65
|
|
|
public function exists(string $sName) : bool |
|
66
|
|
|
{ |
|
67
|
|
|
return isset($_COOKIE[$sName]); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|