2012-07-26 104 views
3

如何在Joomla 1.5中自动登录用户。我正在使用这个代码:Joomla自动登录

global $mainframe; 

$db =& JFactory::getDBO(); 

$query = ‘SELECT `id`, `password`, `gid`’. ‘ FROM `#__users`’. ‘ WHERE username=’ . $db->Quote(JRequest::getVar(‘username’, null)). ‘ AND password=’ . `enter code here` $db->Quote(JRequest::getVar(‘passw’, null)); 

$db->setQuery($query); 
$result = $db->loadObject(); 

    if($result) { 
     JPluginHelper::importPlugin(‘user’); 
     $response->username = JRequest::getVar(‘username’, null); 
     $result = $mainframe->triggerEvent(‘onLoginUser’, array((array)$response, $options)); 
    } 

$mainframe->redirect(‘XXXXXXXXXXXX’); 

我哪里错了?

回答

1

添加代码此之上,它会解决这个问题

jimport(‘joomla.user.helper’); 
-1

//自动登录定制由阿克拉姆阿巴西

$mainframe = JFactory::getApplication(); 
$credentials = array(); 
$credentials['username'] = $app->input->get('username', '', 'string'); 
$credentials['password'] = $app->input->get('password', '', 'raw'); 
$mainframe->login($credentials); 
//$mainframe->redirect(JRoute::_('index.php', false));