/** * This method should handle any logout logic and report back to the subject * * @param array $user Holds the user data. * @param array $options Array holding options (client, ...). * * @return object True on success * * @since 1.5 */ public function onUserLogout($user, $options = array()) { $my = JFactory::getUser(); $session = JFactory::getSession(); // Make sure we're a valid user first if ($user['id'] == 0 && !$my->get('tmp_user')) { return true; } // Check to see if we're deleting the current session if ($my->get('id') == $user['id'] && $options['clientid'] == $this->app->getClientId()) { // Hit the user last visit field $my->setLastVisit(); // Destroy the php session for this user $session->destroy(); } // Enable / Disable Forcing logout all users with same userid $forceLogout = $this->params->get('forceLogout', 1); if ($forceLogout) { $query = $this->db->getQuery(true)->delete($this->db->quoteName('#__session'))->where($this->db->quoteName('userid') . ' = ' . (int) $user['id'])->where($this->db->quoteName('client_id') . ' = ' . (int) $options['clientid']); try { $this->db->setQuery($query)->execute(); } catch (RuntimeException $e) { return false; } } // Delete "user state" cookie used for reverse caching proxies like Varnish, Nginx etc. $conf = JFactory::getConfig(); $cookie_domain = $conf->get('cookie_domain', ''); $cookie_path = $conf->get('cookie_path', '/'); if ($this->app->isSite()) { $this->app->input->cookie->set("joomla_user_state", "", time() - 86400, $cookie_path, $cookie_domain, 0); } return true; }
/** * This method should handle any logout logic and report back to the subject * * @param array $user Holds the user data. * @param array $options Array holding options (client, ...). * * @return object True on success * * @since 1.5 */ public function onUserLogout($user, $options = array()) { $my = JFactory::getUser(); $session = JFactory::getSession(); // Make sure we're a valid user first if ($user['id'] == 0 && !$my->get('tmp_user')) { return true; } // Check to see if we're deleting the current session if ($my->get('id') == $user['id'] && $options['clientid'] == $this->app->getClientId()) { // Hit the user last visit field $my->setLastVisit(); // Destroy the php session for this user $session->destroy(); } // Enable / Disable Forcing logout all users with same userid $forceLogout = $this->params->get('forceLogout', 1); if ($forceLogout) { $query = $this->db->getQuery(true)->delete($this->db->quoteName('#__session'))->where($this->db->quoteName('userid') . ' = ' . (int) $user['id'])->where($this->db->quoteName('client_id') . ' = ' . (int) $options['clientid']); try { $this->db->setQuery($query)->execute(); } catch (RuntimeException $e) { return false; } } return true; }
/** * This method should handle any logout logic and report back to the subject * * @param array $user Holds the user data. * @param array $options Array holding options (client, ...). * * @return object True on success * * @since 1.5 */ public function onUserLogout($user, $options = array()) { $my = JFactory::getUser(); $session = JFactory::getSession(); // Make sure we're a valid user first if ($user['id'] == 0 && !$my->get('tmp_user')) { return true; } // Check to see if we're deleting the current session if ($my->get('id') == $user['id'] && $options['clientid'] == $this->app->getClientId()) { // Hit the user last visit field $my->setLastVisit(); // Destroy the php session for this user $session->destroy(); } // Force logout all users with that userid $query = $this->db->getQuery(true)->delete($this->db->quoteName('#__session'))->where($this->db->quoteName('userid') . ' = ' . (int) $user['id'])->where($this->db->quoteName('client_id') . ' = ' . (int) $options['clientid']); $this->db->setQuery($query)->execute(); return true; }