title: logout programmatically with joomla
body: <p>I need to customize a method in a component. I need to make different action (deleting a user and other info) and then logout the user programmatically (not with a button link), how can I achieve this?</p>
  
  <p>I've tried to do this at the end of the method:</p>
  
  <pre><code>$return   = JRoute::_('index.php?option=com_users&amp;task=user.logout', true);
  $this-&gt;setRedirect($return,$msg);
  </code></pre>
  
  <p>But this gives a invalid token message.</p>
  
  <p>Thanks</p>