当前位置: 首页>>代码示例>>PHP>>正文


PHP JApplicationCms::checkSession方法代码示例

本文整理汇总了PHP中JApplicationCms::checkSession方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCms::checkSession方法的具体用法?PHP JApplicationCms::checkSession怎么用?PHP JApplicationCms::checkSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JApplicationCms的用法示例。


在下文中一共展示了JApplicationCms::checkSession方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onUserLogin

 /**
  * This method should handle any login logic and report back to the subject
  *
  * @param   array  $user     Holds the user data
  * @param   array  $options  Array holding options (remember, autoregister, group)
  *
  * @return  boolean  True on success
  *
  * @since   1.5
  */
 public function onUserLogin($user, $options = array())
 {
     $instance = $this->_getUser($user, $options);
     // If _getUser returned an error, then pass it back.
     if ($instance instanceof Exception) {
         return false;
     }
     // If the user is blocked, redirect with an error
     if ($instance->block == 1) {
         $this->app->enqueueMessage(JText::_('JERROR_NOLOGIN_BLOCKED'), 'warning');
         return false;
     }
     // Authorise the user based on the group information
     if (!isset($options['group'])) {
         $options['group'] = 'USERS';
     }
     // Check the user can login.
     $result = $instance->authorise($options['action']);
     if (!$result) {
         $this->app->enqueueMessage(JText::_('JERROR_LOGIN_DENIED'), 'warning');
         return false;
     }
     // Mark the user as logged in
     $instance->guest = 0;
     $session = JFactory::getSession();
     // Grab the current session ID
     $oldSessionId = $session->getId();
     // Fork the session
     $session->fork();
     $session->set('user', $instance);
     // Ensure the new session's metadata is written to the database
     $this->app->checkSession();
     // Purge the old session
     $query = $this->db->getQuery(true)->delete('#__session')->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($oldSessionId));
     try {
         $this->db->setQuery($query)->execute();
     } catch (RuntimeException $e) {
         // The old session is already invalidated, don't let this block logging in
     }
     // Hit the user last visit field
     $instance->setLastVisit();
     // Add "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", "logged_in", 0, $cookie_path, $cookie_domain, 0);
     }
     return true;
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:60,代码来源:joomla.php

示例2: onUserLogin

 /**
  * This method should handle any login logic and report back to the subject
  *
  * @param   array  $user     Holds the user data
  * @param   array  $options  Array holding options (remember, autoregister, group)
  *
  * @return  boolean  True on success
  *
  * @since   1.5
  */
 public function onUserLogin($user, $options = array())
 {
     $instance = $this->_getUser($user, $options);
     // If _getUser returned an error, then pass it back.
     if ($instance instanceof Exception) {
         return false;
     }
     // If the user is blocked, redirect with an error
     if ($instance->get('block') == 1) {
         $this->app->enqueueMessage(JText::_('JERROR_NOLOGIN_BLOCKED'), 'warning');
         return false;
     }
     // Authorise the user based on the group information
     if (!isset($options['group'])) {
         $options['group'] = 'USERS';
     }
     // Check the user can login.
     $result = $instance->authorise($options['action']);
     if (!$result) {
         $this->app->enqueueMessage(JText::_('JERROR_LOGIN_DENIED'), 'warning');
         return false;
     }
     // Mark the user as logged in
     $instance->set('guest', 0);
     // Register the needed session variables
     $session = JFactory::getSession();
     $session->set('user', $instance);
     // Check to see the the session already exists.
     $this->app->checkSession();
     // Update the user related fields for the Joomla sessions table.
     $query = $this->db->getQuery(true)->update($this->db->quoteName('#__session'))->set($this->db->quoteName('guest') . ' = ' . $this->db->quote($instance->guest))->set($this->db->quoteName('username') . ' = ' . $this->db->quote($instance->username))->set($this->db->quoteName('userid') . ' = ' . (int) $instance->id)->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($session->getId()));
     try {
         $this->db->setQuery($query)->execute();
     } catch (RuntimeException $e) {
         return false;
     }
     // Hit the user last visit field
     $instance->setLastVisit();
     // Add "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", "logged_in", 0, $cookie_path, $cookie_domain, 0);
     }
     return true;
 }
开发者ID:ITPrism,项目名称:GamificationDistribution,代码行数:57,代码来源:joomla.php

示例3: onUserLogin

 /**
  * This method should handle any login logic and report back to the subject
  *
  * @param   array  $user     Holds the user data
  * @param   array  $options  Array holding options (remember, autoregister, group)
  *
  * @return  boolean  True on success
  *
  * @since   1.5
  */
 public function onUserLogin($user, $options = array())
 {
     $instance = $this->_getUser($user, $options);
     // If _getUser returned an error, then pass it back.
     if ($instance instanceof Exception) {
         return false;
     }
     // If the user is blocked, redirect with an error
     if ($instance->get('block') == 1) {
         $this->app->enqueueMessage(JText::_('JERROR_NOLOGIN_BLOCKED'), 'warning');
         return false;
     }
     // Authorise the user based on the group information
     if (!isset($options['group'])) {
         $options['group'] = 'USERS';
     }
     // Check the user can login.
     $result = $instance->authorise($options['action']);
     if (!$result) {
         $this->app->enqueueMessage(JText::_('JERROR_LOGIN_DENIED'), 'warning');
         return false;
     }
     // Mark the user as logged in
     $instance->set('guest', 0);
     // If the user has an outdated hash, update it.
     if (substr($user['password'], 0, 4) != '$2y$' && $this->useStrongEncryption && JCrypt::hasStrongPasswordSupport() == true) {
         if (strlen($user['password']) > 55) {
             $user['password'] = substr($user['password'], 0, 55);
             JFactory::getApplication()->enqueueMessage(JText::_('JLIB_USER_ERROR_PASSWORD_TRUNCATED'), 'notice');
         }
         $instance->password = password_hash($user['password'], PASSWORD_BCRYPT);
         $instance->save();
     }
     // Register the needed session variables
     $session = JFactory::getSession();
     $session->set('user', $instance);
     // Check to see the the session already exists.
     $this->app->checkSession();
     // Update the user related fields for the Joomla sessions table.
     $query = $this->db->getQuery(true)->update($this->db->quoteName('#__session'))->set($this->db->quoteName('guest') . ' = ' . $this->db->quote($instance->guest))->set($this->db->quoteName('username') . ' = ' . $this->db->quote($instance->username))->set($this->db->quoteName('userid') . ' = ' . (int) $instance->id)->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($session->getId()));
     $this->db->setQuery($query)->execute();
     // Hit the user last visit field
     $instance->setLastVisit();
     return true;
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:55,代码来源:joomla.php

示例4: onUserLogin

 /**
  * This method should handle any login logic and report back to the subject
  *
  * @param   array  $user     Holds the user data
  * @param   array  $options  Array holding options (remember, autoregister, group)
  *
  * @return  boolean  True on success
  *
  * @since   1.5
  */
 public function onUserLogin($user, $options = array())
 {
     $instance = $this->_getUser($user, $options);
     // If _getUser returned an error, then pass it back.
     if ($instance instanceof Exception) {
         return false;
     }
     // If the user is blocked, redirect with an error
     if ($instance->get('block') == 1) {
         $this->app->enqueueMessage(JText::_('JERROR_NOLOGIN_BLOCKED'), 'warning');
         return false;
     }
     // Authorise the user based on the group information
     if (!isset($options['group'])) {
         $options['group'] = 'USERS';
     }
     // Check the user can login.
     $result = $instance->authorise($options['action']);
     if (!$result) {
         $this->app->enqueueMessage(JText::_('JERROR_LOGIN_DENIED'), 'warning');
         return false;
     }
     // Mark the user as logged in
     $instance->set('guest', 0);
     // Register the needed session variables
     $session = JFactory::getSession();
     $session->set('user', $instance);
     // Check to see the the session already exists.
     $this->app->checkSession();
     // Update the user related fields for the Joomla sessions table.
     $query = $this->db->getQuery(true)->update($this->db->quoteName('#__session'))->set($this->db->quoteName('guest') . ' = ' . $this->db->quote($instance->guest))->set($this->db->quoteName('username') . ' = ' . $this->db->quote($instance->username))->set($this->db->quoteName('userid') . ' = ' . (int) $instance->id)->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($session->getId()));
     $this->db->setQuery($query)->execute();
     // Hit the user last visit field
     $instance->setLastVisit();
     return true;
 }
开发者ID:01J,项目名称:topm,代码行数:46,代码来源:joomla.php


注:本文中的JApplicationCms::checkSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。