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


PHP Zend_Session::_regenerateIdState方法代码示例

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


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

示例1: regenerateId

 /**
  * regenerateId() - Regenerate the session id.  Best practice is to call this after
  * session is started.  If called prior to session starting, session id will be regenerated
  * at start time.
  *
  * @throws Zend_Session_Exception
  * @return void
  */
 public static function regenerateId()
 {
     if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) {
         /** @see Zend_Session_Exception */
         // require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception("You must call " . __CLASS__ . '::' . __FUNCTION__ . "() before any output has been sent to the browser; output started in {$filename}/{$linenum}");
     }
     if (self::$_sessionStarted && self::$_regenerateIdState <= 0) {
         if (!self::$_unitTestEnabled) {
             session_regenerate_id(true);
         }
         self::$_regenerateIdState = 1;
     } else {
         /**
                      * @todo If we can detect that this requester had no session previously,
                      *       then why regenerate the id before the session has started?
                      *       Feedback wanted for:
                      //
                     if (isset($_COOKIE[session_name()]) || (!use only cookies && isset($_REQUEST[session_name()]))) {
                         self::$_regenerateIdState = 1;
                     } else {
                         self::$_regenerateIdState = -1;
                     }
                     //*/
         self::$_regenerateIdState = -1;
     }
 }
开发者ID:openbizx,项目名称:openbizx-cubix,代码行数:35,代码来源:Session.php

示例2: start

 /**
  * start() - Start the session.
  *
  * @param bool|array $options  OPTIONAL Either user supplied options, or flag indicating if start initiated automatically
  * @throws Zend_Session_Exception
  * @return void
  */
 public static function start($options = false)
 {
     // Check to see if we've been passed an invalid session ID
     if (self::getId() && !self::_checkId(self::getId())) {
         // Generate a valid, temporary replacement
         self::setId(md5(self::getId()));
         // Force a regenerate after session is started
         self::$_regenerateIdState = -1;
     }
     if (self::$_sessionStarted && self::$_destroyed) {
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.');
     }
     if (self::$_sessionStarted) {
         if ($options === true) {
             return;
         } else {
             self::writeClose();
         }
     }
     // make sure our default options (at the least) have been set
     if (!self::$_defaultOptionsSet) {
         self::setOptions(is_array($options) ? $options : array());
     }
     if (!self::getId() && ini_get('session.use_cookies') == 1 && !empty($_COOKIE[session_name()])) {
         self::setId($_COOKIE[session_name()]);
     }
     if (!self::getId() && !empty($_REQUEST[session_name()])) {
         self::setId($_REQUEST[session_name()]);
     }
     if (!self::getId()) {
         self::setId(sha1(uniqid('', true)));
     }
     // In strict mode, do not allow auto-starting Zend_Session, such as via "new Zend_Session_Namespace()"
     if (self::$_strict && $options === true) {
         /** @see Zend_Session_Exception */
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('You must explicitly start the session with Zend_Session::start() when session options are set to strict.');
     }
     $filename = $linenum = null;
     if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) {
         /** @see Zend_Session_Exception */
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception("Session must be started before any output has been sent to the browser;" . " output started in {$filename}/{$linenum}");
     }
     // See http://www.php.net/manual/en/ref.session.php for explanation
     if (!self::$_writeClosed && !self::$_unitTestEnabled && defined('SID')) {
         /** @see Zend_Session_Exception */
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('session has already been started by session.auto-start or session_start()');
     }
     /**
      * Hack to throw exceptions on start instead of php errors
      * @see http://framework.zend.com/issues/browse/ZF-1325
      */
     $errorLevel = is_int(self::$_throwStartupExceptions) ? self::$_throwStartupExceptions : E_ALL;
     /** @see Zend_Session_Exception */
     if (!self::$_unitTestEnabled) {
         if (self::$_throwStartupExceptions) {
             require_once 'Zend/Session/Exception.php';
             set_error_handler(array('Zend_Session_Exception', 'handleSessionStartError'), $errorLevel);
         }
         $hasSessionId = (bool) self::getId();
         $startedCleanly = session_start();
         if (self::$_throwStartupExceptions) {
             restore_error_handler();
         }
         if (!$startedCleanly || Zend_Session_Exception::$sessionStartError != null) {
             if (self::$_throwStartupExceptions) {
                 set_error_handler(array('Zend_Session_Exception', 'handleSilentWriteClose'), $errorLevel);
             }
             session_write_close();
             if (self::$_throwStartupExceptions) {
                 restore_error_handler();
                 throw new Zend_Session_Exception(__CLASS__ . '::' . __FUNCTION__ . '() - ' . Zend_Session_Exception::$sessionStartError);
             }
         }
     } else {
         $_SESSION = array();
         if (!session_id()) {
             session_id(md5(uniqid(mt_rand(), true)));
         }
     }
     parent::$_readable = true;
     parent::$_writable = true;
     self::$_sessionStarted = true;
     self::$_writeClosed = false;
     if (self::$_regenerateIdState === -1) {
         self::regenerateId();
     }
     // run validators if they exist
     if (isset($_SESSION['__ZF']['VALID'])) {
         self::_processValidators();
//.........这里部分代码省略.........
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:101,代码来源:Session.php

示例3: regenerateId

 /**
  * regenerateId() - Regenerate the session id.  Best practice is to call this after
  * session is started.  If called prior to session starting, session id will be regenerated
  * at start time.
  *
  * @throws Zend_Session_Exception
  * @return void
  */
 public static function regenerateId()
 {
     if (headers_sent($filename, $linenum)) {
         throw new Zend_Session_Exception("You must call " . __CLASS__ . '::' . __FUNCTION__ . "() before any output has been sent to the browser; output started in {$filename}/{$linenum}");
     }
     if (self::$_sessionStarted && self::$_regenerateIdState <= 0) {
         session_regenerate_id(true);
         self::$_regenerateIdState = 1;
     } else {
         /*
         // If we can detect that this requester had no session previously,
         // then why regenerate the id before the session has started?
         // Feedback wanted for:
         if (isset($_COOKIE[session_name()])
             || (!use only cookies && isset($_REQUEST[session_name()]))) {
             self::$_regenerateIdState = 1;
         } else {
             self::$_regenerateIdState = -1;
         }
         */
         self::$_regenerateIdState = -1;
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:31,代码来源:Session.php

示例4: regenerateId

 /**
  * regenerateId() - Regenerate the session id.  Best practice is to call this after
  * session is started.  If called prior to session starting, session id will be regenerated
  * at start time.
  *
  * @throws Zend_Session_Exception
  * @return void
  */
 public static function regenerateId()
 {
     if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) {
         /** @see Zend_Session_Exception */
         // require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception("You must call " . __CLASS__ . '::' . __FUNCTION__ . "() before any output has been sent to the browser; output started in {$filename}/{$linenum}");
     }
     if (!self::$_sessionStarted) {
         self::$_regenerateIdState = -1;
     } else {
         if (!self::$_unitTestEnabled) {
             session_regenerate_id(true);
         }
         self::$_regenerateIdState = 1;
     }
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:24,代码来源:Session.php

示例5: start

 /**
  * start() - Start the session.
  *
  * @param bool|array $options  OPTIONAL Either user supplied options, or flag indicating if start initiated automatically
  * @throws Zend_Session_Exception
  * @return void
  */
 public static function start($options = false)
 {
     // Check to see if we've been passed an invalid session ID
     if (self::getId() && !self::_checkId(self::getId())) {
         // Generate a valid, temporary replacement
         self::setId(md5(self::getId()));
         // Force a regenerate after session is started
         self::$_regenerateIdState = -1;
     }
     if (self::$_sessionStarted && self::$_destroyed) {
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.');
     }
     if (self::$_sessionStarted) {
         return;
         // already started
     }
     // make sure our default options (at the least) have been set
     if (!self::$_defaultOptionsSet) {
         self::setOptions(is_array($options) ? $options : array());
     }
     // In strict mode, do not allow auto-starting Zend_Session, such as via "new Zend_Session_Namespace()"
     if (self::$_strict && $options === true) {
         /** @see Zend_Session_Exception */
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('You must explicitly start the session with Zend_Session::start() when session options are set to strict.');
     }
     $filename = $linenum = null;
     if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) {
         /** @see Zend_Session_Exception */
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception("Session must be started before any output has been sent to the browser;" . " output started in {$filename}/{$linenum}");
     }
     // See http://www.php.net/manual/en/ref.session.php for explanation
     if (!self::$_unitTestEnabled && defined('SID')) {
         /** @see Zend_Session_Exception */
         require_once 'Zend/Session/Exception.php';
         throw new Zend_Session_Exception('session has already been started by session.auto-start or session_start()');
     }
     /**
      * Hack to throw exceptions on start instead of php errors
      * @see http://framework.zend.com/issues/browse/ZF-1325
      */
     $errorLevel = is_int(self::$_throwStartupExceptions) ? self::$_throwStartupExceptions : E_ALL;
     // alcalbg - do not start session for robots
     $is_human = true;
     $robots = array('googlebot' => 'Googlebot', 'msnbot' => 'MSNBot', 'baiduspider' => 'Baiduspider', 'bingbot' => 'Bing', 'slurp' => 'Inktomi Slurp', 'yahoo' => 'Yahoo', 'askjeeves' => 'AskJeeves', 'fastcrawler' => 'FastCrawler', 'infoseek' => 'InfoSeek Robot 1.0', 'lycos' => 'Lycos', 'yandex' => 'YandexBot', 'newrelic' => 'NewRelicPinger');
     foreach ($robots as $key => $value) {
         if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], $value) !== false) {
             $is_human = false;
             break;
         }
     }
     /** @see Zend_Session_Exception */
     if ($is_human && !self::$_unitTestEnabled) {
         if (self::$_throwStartupExceptions) {
             require_once 'Zend/Session/Exception.php';
             set_error_handler(array('Zend_Session_Exception', 'handleSessionStartError'), $errorLevel);
         }
         $startedCleanly = session_start();
         if (self::$_throwStartupExceptions) {
             restore_error_handler();
         }
         if (!$startedCleanly || Zend_Session_Exception::$sessionStartError != null) {
             if (self::$_throwStartupExceptions) {
                 set_error_handler(array('Zend_Session_Exception', 'handleSilentWriteClose'), $errorLevel);
             }
             session_write_close();
             if (self::$_throwStartupExceptions) {
                 restore_error_handler();
                 throw new Zend_Session_Exception(__CLASS__ . '::' . __FUNCTION__ . '() - ' . Zend_Session_Exception::$sessionStartError);
             }
         }
     }
     parent::$_readable = true;
     parent::$_writable = true;
     self::$_sessionStarted = true;
     if (self::$_regenerateIdState === -1) {
         self::regenerateId();
     }
     // run validators if they exist
     if (isset($_SESSION['__ZF']['VALID'])) {
         self::_processValidators();
     }
     self::_processStartupMetadataGlobal();
 }
开发者ID:georgepaul,项目名称:socialstrap,代码行数:93,代码来源:Session.php


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