title: How to create a command console that will expire/destroy a session in Symfony2?
body: <p>Guys i want to create a command console that will expire a session or destroy the session in Symfony 2? here's my initial code and its not working :( thanks hope you can help me</p>
  
  <pre><code>public function configure()
      {
          $this
              -&gt;setName('pat:session:delete')
              -&gt;setDescription('Delete a existing session')
              -&gt;addArgument('session_id', InputArgument::REQUIRED, 'The ID of session that will destroy')
          ;
      }
  
      public function execute(InputInterface $input, OutputInterface $output)
      {
          $sessionId = $input-&gt;getArgument('session_id');
  
          $sessionQuery = SessionQuery::create()
              -&gt;filterById($sessionId)-&gt;findOne()-&gt;toArray();
  
          $session = $this-&gt;getContainer()-&gt;get('session');
  
          //Option 1
          $session-&gt;migrate($destroy = false, $lifetime = null);
  
          //Option 2
          $session-&gt;invalidate();
  
          //Option 3 
          $session-&gt;getMetadataBag()-&gt;stampNew(1);
  
          //Option 4
          $session-&gt;remove($sessionQuery["Id"]);
  
      }
  </code></pre>