1 | <?php |
||
2 | /** |
||
3 | * Creating the session as a $di service. |
||
4 | */ |
||
5 | return [ |
||
6 | // Services to add to the container. |
||
7 | "services" => [ |
||
8 | "session" => [ |
||
9 | "active" => defined("ANAX_WITH_SESSION") && ANAX_WITH_SESSION, // true|false |
||
10 | "shared" => true, |
||
11 | "callback" => function () { |
||
12 | $session = new \Anax\Session\Session(); |
||
13 | |||
14 | // Load the configuration files |
||
15 | $cfg = $this->get("configuration"); |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
16 | $config = $cfg->load("session"); |
||
17 | |||
18 | // Set session name |
||
19 | $name = $config["config"]["name"] ?? null; |
||
20 | if (is_string($name)) { |
||
21 | $session->name($name); |
||
22 | } |
||
23 | |||
24 | $session->start(); |
||
25 | |||
26 | return $session; |
||
27 | } |
||
28 | ], |
||
29 | ], |
||
30 | ]; |
||
31 |