本文整理汇总了PHP中Zend_Session::_sessionStarted方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Session::_sessionStarted方法的具体用法?PHP Zend_Session::_sessionStarted怎么用?PHP Zend_Session::_sessionStarted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Session
的用法示例。
在下文中一共展示了Zend_Session::_sessionStarted方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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)
{
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;
/** @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);
}
$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();
}
示例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)
{
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) {
throw new Zend_Session_Exception('You must explicitly start the session with Zend_Session::start() when session options are set to strict.');
}
if (headers_sent($filename, $linenum)) {
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 (defined('SID')) {
throw new Zend_Session_Exception('session has already been started by session.auto-start or session_start()');
}
session_start();
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();
}
示例3: writeClose
/**
* writeClose() - Shutdown the sesssion, close writing and detach $_SESSION from the back-end storage mechanism.
* This will complete the internal data transformation on this request.
*
* @param bool $readonly - OPTIONAL remove write access (i.e. throw error if Zend_Session's attempt writes)
* @return void
*/
public static function writeClose($readonly = true)
{
if (self::$_writeClosed) {
return;
}
if ($readonly) {
parent::$_writable = false;
}
if (!self::$_unitTestEnabled) {
session_write_close();
session_id('');
}
session_write_close();
self::$_writeClosed = true;
self::$_sessionStarted = false;
self::$_defaultOptionsSet = false;
}
示例4: 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();
}