本文整理汇总了PHP中Zend_Session::getIterator方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Session::getIterator方法的具体用法?PHP Zend_Session::getIterator怎么用?PHP Zend_Session::getIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Session
的用法示例。
在下文中一共展示了Zend_Session::getIterator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
if (isset($this->savePath)) {
Zend_Session::setOptions(array('save_path' => $this->savePath));
unset($this->savePath);
}
$old = error_reporting(E_ALL | E_STRICT);
$this->assertTrue($old === error_reporting(E_ALL | E_STRICT), 'something associated with a particular test altered error_reporting to something other than E_STRICT');
restore_error_handler();
Zend_Session_Namespace::unlockAll();
// @todo: cleanup
if (count($this->error_list)) {
echo "**** Errors: ";
print_r($this->error_list);
}
// unset all namespaces
foreach (Zend_Session::getIterator() as $space) {
try {
Zend_Session::namespaceUnset($space);
} catch (Zend_Session_Exception $e) {
$this->assertRegexp('/read.only/i', $e->getMessage());
return;
}
}
}
示例2: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
/**
* Pegando o helper Redirector
*/
$this->_redirect = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
/*
* Instanciando as variáveis de sessão do zend_auth
*/
$authNamespace = new Zend_Session_Namespace('Zend_Auth');
/**
* Copiando em variáves o modulo, controlle e action
*/
$module = strtolower($request->getModuleName());
$controller = strtolower($request->getControllerName());
$action = strtolower($request->getActionName());
/**
* Se o usuário estiver autenticado
*/
if (Zend_Auth::getInstance()->hasIdentity()) {
if (isset($authNamespace->timeout) && time() > $authNamespace->timeout) {
/**
* limpa a identidade do usuário que está um longo período sem acessar o controller
*/
$request->setModuleName('default');
$request->setControllerName('login');
$request->setActionName('logout');
$authNamespace->erro = 'Sua sessão expirou, favor logar novamente';
} else {
/**
* Usuário está ativo - atualizamos o time da sessão.
*/
$authNamespace->timeout = strtotime(self::$_ZEND_SESSION_NAMESPACE_EXPIRATION_SECONDS . " seconds");
/**
* Renovando o timeout das variáves de sessão
*/
$namesspaces = Zend_Session::getIterator();
$namesspacesArrayCopy = $namesspaces->getArrayCopy();
foreach ($namesspacesArrayCopy as $namesspace) {
$namesspace_each = new Zend_Session_Namespace($namesspace);
//$namesspace_each->setExpirationSeconds(self::$_ZEND_SESSION_NAMESPACE_EXPIRATION_SECONDS);
$namesspace_each->timeout = strtotime(self::$_ZEND_SESSION_NAMESPACE_EXPIRATION_SECONDS . " seconds");
$temp = $namesspace_each->timeout;
}
}
}
/** Se o usuário não possuir identidade ou a identidade foi removida devido ao timeout,
* redirecionamos ele para a tela de login.
*/
if (!Zend_Auth::getInstance()->hasIdentity()) {
if (!($module == 'default' && $controller == 'login' && $action == 'index') && !($module == 'default' && $controller == 'login' && $action == 'ajaxbanco')) {
$request->setModuleName('default');
$request->setControllerName('login');
$request->setActionName('index');
$request->setParam('sessao', 'expirada');
}
return;
}
}
示例3: tearDown
/**
* Cleanup operations after each test method is run
*
* @return void
*/
public function tearDown()
{
ini_set('session.save_path', $this->_savePath);
$this->assertSame(E_ALL | E_STRICT, error_reporting(E_ALL | E_STRICT), 'A test altered error_reporting to something other than E_ALL | E_STRICT');
Zend_Session_Namespace::unlockAll();
// unset all namespaces
foreach (Zend_Session::getIterator() as $space) {
try {
Zend_Session::namespaceUnset($space);
} catch (Zend_Session_Exception $e) {
$this->assertRegexp('/read.only/i', $e->getMessage());
return;
}
}
}
示例4: _ZF_expireAll
public function _ZF_expireAll($args)
{
Zend_Session_Core::setOptions(array('remember_me_seconds' => 15, 'gc_probability' => 2));
session_id($args[0]);
if (isset($args[1]) && !empty($args[1])) {
$s = new Zend_Session($args[1]);
} else {
$s = new Zend_Session();
}
$result = '';
foreach ($s->getIterator() as $key => $val) {
$result .= "{$key} === {$val};";
}
$core = Zend_Session_Core::getInstance();
$core->expireSessionCookie();
$core->writeClose();
echo $result;
}
示例5: getIterator
/**
* 登録済み名前空間をすべて取得
*
* @static
* @access public
*/
public static function getIterator()
{
return parent::getIterator();
}
示例6: testUnsetAllNamespace
/**
* test unsetAll keys in default namespace
* expect namespace will contain no keys
*/
public function testUnsetAllNamespace()
{
$s = new Zend_Session('somenamespace');
$result = '';
foreach ($s->getIterator() as $key => $val) {
$result .= "{$key} === {$val};";
}
$this->assertTrue(empty($result), "tearDown failure, found keys in 'somenamespace' namespace: '{$result}'");
$s->a = 'apple';
$s->lock();
$s->unlock();
$s->p = 'papaya';
$s->c = 'cherry';
$s = new Zend_Session('somenamespace');
$result = '';
foreach ($s->getIterator() as $key => $val) {
$result .= "{$key} === {$val};";
}
$this->assertTrue($result === 'a === apple;p === papaya;c === cherry;', "unsetAll() setup for test failed: '{$result}'");
$s->unsetAll();
$result = '';
foreach ($s->getIterator() as $key => $val) {
$result .= "{$key} === {$val};";
}
$this->assertTrue(empty($result), "unsetAll() did not remove keys from namespace: '{$result}'");
}