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


PHP SessionManager::destroy方法代码示例

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


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

示例1: logout

 /**
  * Log out the current user.
  *
  * @param string $url     URL to redirect user to after logging out.
  * @param bool   $destroy Should we destroy the session (true) or just reset it
  * (false); destroy is for log out, reset is for expiration.
  *
  * @return string     Redirect URL (usually same as $url, but modified in
  * some authentication modules).
  */
 public function logout($url, $destroy = true)
 {
     // Perform authentication-specific cleanup and modify redirect URL if
     // necessary.
     $url = $this->getAuth()->logout($url);
     // Clear out the cached user object and session entry.
     $this->currentUser = false;
     unset($this->session->userId);
     $this->cookieManager->set('loggedOut', 1);
     // Destroy the session for good measure, if requested.
     if ($destroy) {
         $this->sessionManager->destroy();
     } else {
         // If we don't want to destroy the session, we still need to empty it.
         // There should be a way to do this through Zend\Session, but there
         // apparently isn't (TODO -- do this better):
         $_SESSION = [];
     }
     return $url;
 }
开发者ID:htw-pk15,项目名称:vufind,代码行数:30,代码来源:Manager.php

示例2: logoutAction

 public function logoutAction()
 {
     $config = new StandardConfig();
     $manager = new SessionManager($config);
     if ($this->getAuthService()->hasIdentity()) {
         $this->getSessionStorage()->forgetMe();
         $this->getAuthService()->clearIdentity();
         $manager->destroy();
         $this->flashmessenger()->addMessage("You've been logout");
     }
     return $this->redirect()->toRoute('manager');
 }
开发者ID:ravikantmishra,项目名称:ppservice,代码行数:12,代码来源:ManagerController.php

示例3: logout

 /**
  *
  */
 public function logout()
 {
     $this->authService->clearIdentity();
     $this->sessionManager->destroy(['send_expire_cookie' => true, 'clear_storage' => true]);
 }
开发者ID:t4web,项目名称:authentication,代码行数:8,代码来源:InteractiveAuth.php

示例4: _init

 public function _init(Dispatcher $dispatcher)
 {
     // 引入Composer,Yaf扩展的配置项yaf.use_spl_autoload务必设置为1
     if (file_exists(ROOT_PATH . '/vendor/autoload.php')) {
         $loader = (include ROOT_PATH . '/vendor/autoload.php');
         //$loader->add("",ROOT_PATH.'/library');
         //$loader->addPsr4("Zend\\",ROOT_PATH.'/library/Zend');
         Registry::set('loader', $loader);
     }
     // 禁止自动渲染
     $dispatcher->autoRender(FALSE);
     // 保存配置
     $this->_config = Application::app()->getConfig();
     Registry::set('config', $this->_config);
     // 报错设置
     if ($this->_config->global->showError) {
         error_reporting(-1);
         ini_set('display_errors', 'On');
     }
     // 加解密
     if (!empty($this->_config->global->key)) {
         Registry::set('enc', function () {
             $blockCipher = BlockCipher::factory('mcrypt', array('algo' => 'aes'));
             $blockCipher->setKey($this->_config->global->key);
             return $blockCipher;
         });
     }
     // 命令行方式,跳过SESSION
     if (!defined("RUN_IN_CLI")) {
         // 保存路径
         $sessionConfig = $this->_config->session->toArray();
         if (isset($sessionConfig['save_path'])) {
             @mkdir($sessionConfig['save_path'], 0777, true);
         }
         // 配置
         $config = new SessionConfig();
         $config->setOptions($sessionConfig);
         // 会话管理器
         $manager = new SessionManager($config);
         // 开启会话
         $manager->start();
         // 验证会话
         $manager->getValidatorChain()->attach('session.validate', array(new HttpUserAgent(), 'isValid'));
         if (!$manager->isValid()) {
             $manager->destroy();
             throw new \Exception("会话验证失败");
         }
         // 会话Token
         $default = new Zend\Session\Container();
         if (empty($default->offsetGet('securityToken'))) {
             $default->offsetSet('securityToken', md5(uniqid(rand(), true)));
         }
         // 保存实例
         Registry::set('session', $default);
         Registry::set('sm', $manager);
     }
     // 数据库
     Registry::set('db', function () {
         $mysqlMasterConfig = $this->_config->mysql->master->toArray();
         $adapter = new Adapter($mysqlMasterConfig);
         $connect = $adapter->getDriver()->getConnection();
         for ($i = 0; $i < 5; $i++) {
             if ($connect->isConnected()) {
                 break;
             }
             $connect->connect();
         }
         return $adapter;
     });
     // 邮件
     Registry::set('mail', function () {
         $options = new SmtpOptions($this->_config->smtp->toArray());
         $mail = new SmtpTransport();
         $mail->setOptions($options);
         return $mail;
     });
     // 日志
     Registry::set('logger', function () {
         $logger = new Zend\Log\Logger();
         $writer = new Zend\Log\Writer\Stream($this->_config->log->path . '/' . date("Ymd") . ".log");
         $logger->addWriter($writer);
         return $logger;
     });
 }
开发者ID:vfeelit,项目名称:YZend,代码行数:84,代码来源:Bootstrap.php


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