Код: Выделить всё
// create cookie
setCookie('cookie_one', 'value_of_cookie_one' , 0, '/', '.mysite.com');
поэтому в /plugins/user/joomla.php в функции onLoginUser я добавил следующий код, но после входа пользователя я получаю пустую страницу и конечно, файлы cookie не отображаются с помощью EditThisCookie в Chrome. Мой код в функции 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;
}
Подробнее здесь: https://stackoverflow.com/questions/262 ... user-login
Мобильная версия