Problem - I want to check whether the session is set or not in the '__construct' of a 'Controller', but i am getting the following error -
FatalErrorException: Compile Error: Cannot use isset() on the result of a function call (you can use "null !== func()" instead)
The following is the code snippet which is in my '__construct' -
function __construct() {
$request = Request::createFromGlobals();
$session = $request->getSession();
if(!isset($session->get('id'))){
$this->redirect('UserAuthBundle:Auth:login.html.twig');
}
}
If I use '!= null' instead of '!isset' its giving me an error as following -
FatalErrorException: Error: Call to a member function get() on a non-object
Is there any other alternative way so that this can be implemented.
Thanks in advance.