1 | <?php |
||
21 | class Configuration |
||
22 | { |
||
23 | use NativeSessionTrait; |
||
24 | |||
25 | const LIFETIME_FLASH = 300; // 5 minutes |
||
26 | const LIFETIME_SHORT = 600; // 10 minutes |
||
27 | const LIFETIME_NORMAL = 900; // 15 minutes |
||
28 | const LIFETIME_DEFAULT = 1440; // 24 minutes |
||
29 | const LIFETIME_EXTENDED = 3600; // 1 hour |
||
30 | const LIFETIME_INFINITE = PHP_INT_MAX; // Around 1145 years (x86_64) |
||
31 | |||
32 | const TIMEOUT_KEY_DEFAULT = '__SESSIONWARE_TIMEOUT__'; |
||
33 | |||
34 | const SESSION_NAME_DEFAULT = 'PHPSESSID'; |
||
35 | |||
36 | const SESSION_ID_LENGTH = 80; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $name; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $savePath; |
||
47 | |||
48 | /** |
||
49 | * @var int |
||
50 | */ |
||
51 | protected $lifetime; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $timeoutKey; |
||
57 | |||
58 | /** |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $cookiePath; |
||
62 | |||
63 | /** |
||
64 | * @var string |
||
65 | */ |
||
66 | protected $cookieDomain; |
||
67 | |||
68 | /** |
||
69 | * @var bool |
||
70 | */ |
||
71 | protected $cookieSecure; |
||
72 | |||
73 | /** |
||
74 | * @var bool |
||
75 | */ |
||
76 | protected $cookieHttpOnly; |
||
77 | |||
78 | /** |
||
79 | * Configuration constructor. |
||
80 | * |
||
81 | * @param array $configurations |
||
82 | */ |
||
83 | public function __construct(array $configurations = []) |
||
92 | |||
93 | /** |
||
94 | * Retrieve default session settings. |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | protected function getDefaultSessionSettings() : array |
||
116 | |||
117 | /** |
||
118 | * Seed configurations. |
||
119 | * |
||
120 | * @param array $configurations |
||
121 | */ |
||
122 | protected function seedConfigurations(array $configurations) |
||
143 | |||
144 | /** |
||
145 | * Get session name. |
||
146 | * |
||
147 | * @return string |
||
148 | */ |
||
149 | public function getName() : string |
||
153 | |||
154 | /** |
||
155 | * Set session name. |
||
156 | * |
||
157 | * @param string $name |
||
158 | * |
||
159 | * @throws \InvalidArgumentException |
||
160 | * |
||
161 | * @return static |
||
162 | */ |
||
163 | public function setName(string $name) |
||
173 | |||
174 | /** |
||
175 | * Get session cookie path. |
||
176 | * |
||
177 | * @return string |
||
178 | */ |
||
179 | public function getCookiePath() : string |
||
183 | |||
184 | /** |
||
185 | * Set session cookie path. |
||
186 | * |
||
187 | * @param string $cookiePath |
||
188 | * |
||
189 | * @return static |
||
190 | */ |
||
191 | public function setCookiePath(string $cookiePath) |
||
197 | |||
198 | /** |
||
199 | * Get session cookie domain. |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | public function getCookieDomain() : string |
||
207 | |||
208 | /** |
||
209 | * Set session cookie domain. |
||
210 | * |
||
211 | * @param string $cookieDomain |
||
212 | * |
||
213 | * @return static |
||
214 | */ |
||
215 | public function setCookieDomain(string $cookieDomain) |
||
221 | |||
222 | /** |
||
223 | * Is session cookie HTTPS only. |
||
224 | * |
||
225 | * @return bool |
||
226 | */ |
||
227 | public function isCookieSecure() : bool |
||
231 | |||
232 | /** |
||
233 | * Set session cookie HTTPS only. |
||
234 | * |
||
235 | * @param bool $cookieSecure |
||
236 | * |
||
237 | * @return static |
||
238 | */ |
||
239 | public function setCookieSecure(bool $cookieSecure) |
||
245 | |||
246 | /** |
||
247 | * Is session cookie HTTP only. |
||
248 | * |
||
249 | * @return bool |
||
250 | */ |
||
251 | public function isCookieHttpOnly() : bool |
||
255 | |||
256 | /** |
||
257 | * Set session cookie HTTP only. |
||
258 | * |
||
259 | * @param bool $cookieHttpOnly |
||
260 | * |
||
261 | * @return static |
||
262 | */ |
||
263 | public function setCookieHttpOnly(bool $cookieHttpOnly) |
||
269 | |||
270 | /** |
||
271 | * Get session save path. |
||
272 | * |
||
273 | * @return string |
||
274 | */ |
||
275 | public function getSavePath() : string |
||
279 | |||
280 | /** |
||
281 | * Set session save path. |
||
282 | * |
||
283 | * @param string $savePath |
||
284 | * |
||
285 | * @throws \InvalidArgumentException |
||
286 | * |
||
287 | * @return static |
||
288 | */ |
||
289 | public function setSavePath(string $savePath) |
||
299 | |||
300 | /** |
||
301 | * Get session lifetime. |
||
302 | * |
||
303 | * @return int |
||
304 | */ |
||
305 | public function getLifetime() : int |
||
309 | |||
310 | /** |
||
311 | * Set session lifetime. |
||
312 | * |
||
313 | * @param int $lifetime |
||
314 | * |
||
315 | * @throws \InvalidArgumentException |
||
316 | * |
||
317 | * @return static |
||
318 | */ |
||
319 | public function setLifetime(int $lifetime) |
||
329 | |||
330 | /** |
||
331 | * Get session timeout control key. |
||
332 | * |
||
333 | * @return string |
||
334 | */ |
||
335 | public function getTimeoutKey() : string |
||
339 | |||
340 | /** |
||
341 | * Set session timeout control key. |
||
342 | * |
||
343 | * @param string $timeoutKey |
||
344 | * |
||
345 | * @throws \InvalidArgumentException |
||
346 | * |
||
347 | * @return static |
||
348 | */ |
||
349 | public function setTimeoutKey(string $timeoutKey) |
||
359 | } |
||
360 |