Closed samuelvi closed 2 years ago
I just realized that retrieving the session service directly from the container works.
So previous to SF 5.3:
public function __construct(SessionInterface $session)
{
$this-session = $session;
}
public function getWebSession() : SessionInterface
{
return $this->session;
}
And since SF 5.3:
public function __construct(KernelInterface $kernel)
{
$this->kernel = $kernel;
}
public function getWebSession() : SessionInterface
{
return $this->kernel->getContainer()->get('session');
}
Sorry about the confusion, thanks!
Hi, The scenario is as follows:
At this point $this->requestStack->getSession() always returns null. The following error is gotten when trying to retrieve the session from the requestStack instance:
There is currently no session available. (Symfony\Component\HttpFoundation\Exception\SessionNotFoundException)
Thanks!
P.S: Also tried to inject the requestStack via constructor but the same error happens.