title: Joomla auto login
body: <p>How can I auto-login a user in Joomla 1.5. I am using this code:</p>
  
  <pre><code>global $mainframe;
  
  $db =&amp; JFactory::getDBO();  
  
  $query = ‘SELECT `id`, `password`, `gid`’. ‘ FROM `#__users`’. ‘ WHERE username=’ . $db-&gt;Quote( JRequest::getVar(‘username’, null) ). ‘   AND password=’ . `enter code here` $db-&gt;Quote( JRequest::getVar(‘passw’, null) );
  
  $db-&gt;setQuery( $query );
  $result = $db-&gt;loadObject();
  
      if($result) {
         JPluginHelper::importPlugin(‘user’);
         $response-&gt;username = JRequest::getVar(‘username’, null);
         $result = $mainframe-&gt;triggerEvent(‘onLoginUser’, array((array)$response, $options));
      }
  
  $mainframe-&gt;redirect(‘XXXXXXXXXXXX’);
  </code></pre>
  
  <p>Where did I go wrong?</p>