has('q') ? $session->get('q') : NULL; if ($q) { $this->addFlash('info', "Q was found to be $q"); } return new Response($q ? "Q is $q" : "Q is not set"); } /** * @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session * @param \Symfony\Component\HttpFoundation\Request $request * * @return \Symfony\Component\HttpFoundation\Response * * @Route( * name = "session-set", * path = "session/set" * ) */ public function setValue(SessionInterface $session, Request $request) { $q = $request->query->has('q') ? (int) $request->query->get('q') : 0; $session->set('q', $q); $this->addFlash('info', "Q was set to $q"); return new Response("Set q to $q"); } }