| Conditions | 2 |
| Paths | 2 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 3 |
| CRAP Score | 3.9401 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 37 | 2 | public function retrieve(): array |
|
| 38 | { |
||
| 39 | 2 | if ($this->session !== null) { |
|
| 40 | 2 | return $this->session; |
|
| 41 | } |
||
| 42 | |||
| 43 | ini_set('session.gc_maxlifetime', '1800'); |
||
| 44 | ini_set('session.save_handler', 'redis'); |
||
| 45 | ini_set('session.save_path', $this->path); |
||
| 46 | ini_set('session.cookie_domain', $this->domain); |
||
| 47 | ini_set('session.cookie_secure', (string) $this->secure); |
||
| 48 | ini_set('session.cookie_httponly', '1'); |
||
| 49 | |||
| 50 | // When AWS Elasticache DNS resolution fails, PHP throws an error |
||
| 51 | // session_start(): php_network_getaddresses: getaddrinfo failed: Name or service not known |
||
| 52 | // This error is happening on 0.02% of our requests and AWS treat it as transient network |
||
| 53 | // issues. Retrying before giving up might mitigate the problem. |
||
| 54 | retry(3, function () { |
||
| 55 | session_start(); |
||
| 56 | }); |
||
| 57 | |||
| 58 | $this->session = $_SESSION; |
||
| 59 | |||
| 60 | return $this->session; |
||
| 61 | } |
||
| 63 |