Skip to content

Commit

Permalink
Fix empty session value in Symfony adapter
Browse files Browse the repository at this point in the history
The mock session handler used within the tests takes the NULL value (if no cookie is present) and sets it as the id.
This allows the subsequent check upon response to function correctly.
However, when using the native session_id function in production, the NULL value is not returned and `session_id` returns an empty string.
So as to meet these requirements we should instead replace NULL with an empty string to signify no session being present.
  • Loading branch information
eddmann committed Sep 21, 2018
1 parent 2d42ce7 commit 5f5c681
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Bridge/Symfony/SymfonyAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public function handle(ServerRequestInterface $request): ResponseInterface
return (new DiactorosFactory)->createResponse($symfonyResponse);
}

private function loadSessionFromRequest(Request $symfonyRequest): ?string
private function loadSessionFromRequest(Request $symfonyRequest): string
{
if ($this->hasSessionsDisabled()) {
return null;
return '';
}

$this->httpKernel->getContainer()->get('session')->setId(
$sessionId = $symfonyRequest->cookies->get(session_name())
$sessionId = $symfonyRequest->cookies->get(session_name(), '')
);

return $sessionId;
Expand Down

0 comments on commit 5f5c681

Please sign in to comment.