original_string: public function handle(GetResponseEvent $event)
      {
          if (!$this->registered && null !== $this->dispatcher && $event->isMasterRequest()) {
              $this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
              $this->registered = true;
          }
  
          $request = $event->getRequest();
          $session = $request->getSession();
          /*$sessionId = $session->getId();
          if(empty($sessionId))
          {
              $session = null;
          }*/
  
          if (null === $session || null === $token = $session->get('_security_'.$this->contextKey)) {
              $this->context->setToken(null);
  
              return;
          }
  
          $token = unserialize($token);
  
          if (null !== $this->logger) {
              $this->logger->debug('Read SecurityContext from the session');
          }
  
          if ($token instanceof TokenInterface) {
              $token = $this->refreshUser($token);
          } elseif (null !== $token) {
              if (null !== $this->logger) {
                  $this->logger->warning(sprintf('Session includes a "%s" where a security token is expected', is_object($token) ? get_class($token) : gettype($token)));
              }
  
              $token = null;
          }
  
          $this->context->setToken($token);
      }
code: public function handle(GetResponseEvent $event)
      {
          if (!$this->registered && null !== $this->dispatcher && $event->isMasterRequest()) {
              $this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
              $this->registered = true;
          }
  
          $request = $event->getRequest();
          $session = $request->getSession();
          /*$sessionId = $session->getId();
          if(empty($sessionId))
          {
              $session = null;
          }*/
  
          if (null === $session || null === $token = $session->get('_security_'.$this->contextKey)) {
              $this->context->setToken(null);
  
              return;
          }
  
          $token = unserialize($token);
  
          if (null !== $this->logger) {
              $this->logger->debug('Read SecurityContext from the session');
          }
  
          if ($token instanceof TokenInterface) {
              $token = $this->refreshUser($token);
          } elseif (null !== $token) {
              if (null !== $this->logger) {
                  $this->logger->warning(sprintf('Session includes a "%s" where a security token is expected', is_object($token) ? get_class($token) : gettype($token)));
              }
  
              $token = null;
          }
  
          $this->context->setToken($token);
      }
code_tokens: public function handle ( GetResponseEvent $ event ) { if ( ! $ this -> registered && null !== $ this -> dispatcher && $ event -> isMasterRequest ( ) ) { $ this -> dispatcher -> addListener ( KernelEvents :: RESPONSE , array ( $ this , 'onKernelResponse' ) ) ; $ this -> registered = true ; } $ request = $ event -> getRequest ( ) ; $ session = $ request -> getSession ( ) ; /*$sessionId = $session->getId();
          if(empty($sessionId))
          {
              $session = null;
          }*/ if ( null === $ session || null === $ token = $ session -> get ( '_security_' . $ this -> contextKey ) ) { $ this -> context -> setToken ( null ) ; return ; } $ token = unserialize ( $ token ) ; if ( null !== $ this -> logger ) { $ this -> logger -> debug ( 'Read SecurityContext from the session' ) ; } if ( $ token instanceof TokenInterface ) { $ token = $ this -> refreshUser ( $ token ) ; } elseif ( null !== $ token ) { if ( null !== $ this -> logger ) { $ this -> logger -> warning ( sprintf ( 'Session includes a "%s" where a security token is expected' , is_object ( $ token ) ? get_class ( $ token ) : gettype ( $ token ) ) ) ; } $ token = null ; } $ this -> context -> setToken ( $ token ) ; }
docstring: Reads the SecurityContext from the session.
  
  @param GetResponseEvent $event A GetResponseEvent instance
docstring_tokens: Reads the SecurityContext from the session .