1 | <?php |
||
5 | class Cookie |
||
6 | { |
||
7 | /** |
||
8 | * Application Object |
||
9 | * |
||
10 | * @var \System\Application |
||
11 | */ |
||
12 | private $app; |
||
13 | |||
14 | /** |
||
15 | * Constructor |
||
16 | * |
||
17 | * @property object $request |
||
18 | * @param \System\Application $app |
||
19 | */ |
||
20 | public function __construct(Application $app) |
||
24 | |||
25 | /** |
||
26 | * Set new value to cookie |
||
27 | * |
||
28 | * @param string $key |
||
29 | * @param mixed $value |
||
30 | * @param int $hours |
||
31 | * @return void |
||
32 | */ |
||
33 | public function set(string $key, $value, int $hours = 1800, $path = '/') |
||
39 | |||
40 | /** |
||
41 | * Get value from cookies by the given key |
||
42 | * |
||
43 | * @param string $key |
||
44 | * @param mixed $default |
||
45 | * @return mixed |
||
46 | */ |
||
47 | public function get(string $key, $default = null) |
||
51 | |||
52 | /** |
||
53 | * Determine if the cookies has the given key |
||
54 | * |
||
55 | * @param string $key |
||
56 | * @return bool |
||
57 | */ |
||
58 | public function has(string $key) |
||
62 | |||
63 | /** |
||
64 | * Remove the given key from cookie |
||
65 | * |
||
66 | * @param string $key |
||
67 | * @return void |
||
68 | */ |
||
69 | public function remove(string $key) |
||
75 | |||
76 | /** |
||
77 | * Get all cookies data |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | public function all() |
||
85 | |||
86 | /** |
||
87 | * Destroy cookie |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | public function destroy() |
||
98 | } |
||
99 |