PHP - symfony2 - 检查Session是否设置时出错

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.

Manual says:

Warning

isset() only works with variables as passing anything else will result in a parse error. For checking if constants are set use the defined() function.

if ($session->get("token") == $token) {

// user legit

}

or

if ($this->container->get('session')->isStarted()) {

// user legit

}