| Conditions | 5 |
| Paths | 10 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public function destroySession(SessionInterface $session, ?UserInterface $user = null): void |
||
| 16 | { |
||
| 17 | $userToTruncate = $user ?? $session->getUser(); |
||
| 18 | if ($userToTruncate !== null) { |
||
| 19 | $this->sessionStringRepository->truncate($userToTruncate); |
||
| 20 | } |
||
| 21 | |||
| 22 | if ($user === null) { |
||
| 23 | $this->destroyLoginCookies(); |
||
| 24 | $sessionName = session_name(); |
||
| 25 | if ($sessionName) { |
||
| 26 | setcookie($sessionName, '', ['expires' => time() - 42000]); |
||
| 27 | } |
||
| 28 | if (@session_destroy() === false) { |
||
| 29 | throw new RuntimeException('The session could not be destroyed'); |
||
| 30 | } |
||
| 31 | |||
| 32 | $session->setUser(null); |
||
| 33 | } |
||
| 41 |