title: joomla 2.5 login from a conroller method
body: <pre><code> public function login()
  {
  
      $db = JFactory::getDBO();
      $query = $db-&gt;getQuery(true);
      $query="SELECT * FROM #__users WHERE fb_id=".$_REQUEST['val'];
      $db-&gt;setQuery($query);
      $row = $db-&gt;loadRow();
      if(count($row)&gt;0 and is_array($row))
      {       
          jimport('joomla.user.helper');
          $salt = JUserHelper::genRandomPassword(32);
          $crypt = JUserHelper::getCryptedPassword($_REQUEST['val'], $salt);
          $password = $crypt.':'.$salt;
          $query="UPDATE #__users SET password = '".$password."' WHERE fb_id =".$_REQUEST['val'];
          $db-&gt;setQuery($query);
          $db-&gt;query();
          $credentials = array( 'username' =&gt; $row[2], 'password' =&gt; $password);
          $login_site =JFactory::getApplication();
          $login_site-&gt;login($credentials, $options=array());
      }
      header("location:".JURI::base());
  }
  </code></pre>
  
  <p>This method i declared in \components\com_users\controller.php but authentication failing every time while I logging in with that, after redirection user remain at the same state.Please help thanks in advance.</p>