Symfony2: check if a session exists or not.

Is there a way to check if a session exists or not?

I tried this method, but it always gives me “Bravo”. Answer:

$session = $this->getRequest()->hasPreviousSession(); if($session) { return new Response('Bravo !'); } else { return new Response('Oooops !'); } 
+6
source share
1 answer
 $this->container->get('session')->isStarted() 

- this is what you are looking for.

+16
source

Source: https://habr.com/ru/post/945941/


All Articles