1 | <?php |
||
5 | class Session |
||
6 | { |
||
7 | /** |
||
8 | * Application Object |
||
9 | * |
||
10 | * @var \System\Application |
||
11 | */ |
||
12 | private $app; |
||
13 | |||
14 | /** |
||
15 | * Constructor |
||
16 | * |
||
17 | * @param \System\Application $app |
||
18 | */ |
||
19 | public function __construct(Application $app) |
||
23 | |||
24 | /** |
||
25 | * Start session |
||
26 | * |
||
27 | * @return void |
||
28 | */ |
||
29 | public function start() |
||
37 | |||
38 | /** |
||
39 | * Set new value to session |
||
40 | * |
||
41 | * @param string $key |
||
42 | * @param mixed $value |
||
43 | * @return void |
||
44 | */ |
||
45 | public function set(string $key, $value) |
||
49 | |||
50 | /** |
||
51 | * Get value from session by the given key |
||
52 | * |
||
53 | * @param string $key |
||
54 | * @param mixed $default |
||
55 | * @return mixed |
||
56 | */ |
||
57 | public function get(string $key, $default = null) |
||
61 | |||
62 | /** |
||
63 | * Determine if the session has the given key |
||
64 | * |
||
65 | * @param string $key |
||
66 | * @return bool |
||
67 | */ |
||
68 | public function has(string $key) |
||
72 | |||
73 | /** |
||
74 | * Remove the given key from session |
||
75 | * |
||
76 | * @param string $key |
||
77 | * @return void |
||
78 | */ |
||
79 | public function remove(string $key) |
||
83 | |||
84 | /** |
||
85 | * Get value from session by the given key then remove it |
||
86 | * |
||
87 | * @param string $key |
||
88 | * @return mixed |
||
89 | */ |
||
90 | public function pull(string $key) |
||
98 | |||
99 | /** |
||
100 | * Get all session data |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | public function all() |
||
108 | |||
109 | /** |
||
110 | * Destroy session |
||
111 | * |
||
112 | * @return void |
||
113 | */ |
||
114 | public function destroy() |
||
120 | } |
||
121 |