browser = $browser; $this->encoder = $encoder; $this->repository = $repo; } /** * Returns a Session give a cookie value * * @param string $cookieValue * * @return false|Session */ public function getSession($cookieValue) { $session = $this->repository->findOneBy(['token' => $cookieValue]); if (!$session) { return false; } $string = sprintf('%s_%s', $this->browser->getBrowser(), $this->browser->getPlatform()); if (!$this->encoder->isPasswordValid($session->getToken(), $string, $session->getNonce())) { return false; } return $session; } }