0
我有一個joomla 1.5.26站點的問題這個站點與外部數據庫進行通信以處理用戶和服務,爲了溝通我必須創建3個cookie,一個我們在正常的URL使用Chrome的EditThisCookie的網站,我已經做了的市民,用一行代碼smthng像在joomla 1.5用戶登錄創建2個cookie
// create cookie
setCookie('cookie_one', 'value_of_cookie_one' , 0, '/', '.mysite.com');
現在我的問題使用在index.php可以看到它,我想在登錄用戶在登錄後立即創建2個cookie的前端,一個讓我們說有用戶名和第二個會話的session_id
所以在/plugins/user/joomla.php函數onLoginUser我已經添加了下面的代碼,但我得到一個空白頁後用戶登錄,當然沒有餅乾看到使用EditThisCookie的鉻..我的代碼在功能onLoginUser就是這樣,但我不能弄清楚是爲我的錯誤...任何幫助將非常感激你們......
function onLoginUser($user, $options = array())
{
$instance =& $this->_getUser($user, $options);
if ($instance instanceof Exception) {
return false;
}
// If the user is blocked, redirect with an error
if ($instance->get('block') == 1) {
return JError::raiseWarning('SOME_ERROR_CODE', JText::_('E_NOLOGIN_BLOCKED'));
}
//Authorise the user based on the group information
if(!isset($options['group'])) {
$options['group'] = 'USERS';
}
// Chek the user can login.
$result = $instance->authorise($options['action']);
if (!$result) {
JError::raiseWarning(401, JText::_('JERROR_LOGIN_DENIED'));
return false;
}
//Mark the user as logged in
$instance->set('guest', 0);
// Register the needed session variables
$session =& JFactory::getSession();
$session->set('user', $instance);
$db = JFactory::getDBO();
// Check to see the the session already exists.
$app = JFactory::getApplication();
$app->checkSession();
// Update the user related fields for the Joomla sessions table.
$db->setQuery(
'UPDATE '.$db->quoteName('#__session') .
' SET '.$db->quoteName('guest').' = '.$db->quote($instance->get('guest')).',' .
' '.$db->quoteName('username').' = '.$db->quote($instance->get('username')).',' .
' '.$db->quoteName('userid').' = '.(int) $instance->get('id') .
' WHERE '.$db->quoteName('session_id').' = '.$db->quote($session->getId())
);
$db->query();
// Hit the user last visit field
$instance->setLastVisit();
/* ------------------------------------------------------------------------------ */
//Make sure we are in the frontend
if ($app->isSite())
{
// Initialise variables.
$url = $this->params->get('url', JURI::base()) . "?currenturl=" . JURI::base();
$cookie_one = 'value_of_cookie_one';
$cookie_domain = '.mysite.com';
$expire = (time() + 720);
setCookie('ooo_username', $instance->get('username'), $expire, '/', $cookie_domain);
setCookie('ooo_municipality_id', $cookie_one, $expire, '/', $cookie_domain);
setCookie('ooo_session_id', $session->getId(), $expire, '/', $cookie_domain);
// Tell ME the user is logged in
if($this->params->get('ooo_redirection', 0) == 1) {
$app->redirect($url);
}
}
/* ------------------------------------------------------------------------------ */
return true;
}
任何幫助將非常感激你們謝謝!!!!
不要使用的Joomla! 1.5,已經過時,不再支持。 – 2014-10-10 12:11:59