2012-07-26 143 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));