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


PHP Zend_Session::setExpirationSeconds方法代码示例

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


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

示例1: testSetExpirationSeconds

 /**
  * test expiration of namespaces and namespace variables by seconds
  * expect expiration of specified keys/namespace
  */
 public function testSetExpirationSeconds()
 {
     $s = new Zend_Session('expireAll');
     $s->a = 'apple';
     $s->p = 'pear';
     $s->o = 'orange';
     $s->setExpirationSeconds(5);
     $core = Zend_Session_Core::getInstance();
     $core->regenerateId();
     $id = Zend_Session_Core::getId();
     session_write_close();
     // release session so process below can use it
     sleep(4);
     // not long enough for things to expire
     exec($this->script . "expireAll {$id} expireAll", $result);
     $result = $this->sortResult($result);
     $expect = ';a === apple;o === orange;p === pear';
     $this->assertTrue($result === $expect, "iteration over default Zend_Session namespace failed; expecting result === '{$expect}', but got '{$result}'");
     sleep(2);
     // long enough for things to expire (total of 6 seconds waiting, but expires in 5)
     exec($this->script . "expireAll {$id} expireAll", $result);
     $result = array_pop($result);
     $this->assertTrue($result === '', "iteration over default Zend_Session namespace failed; expecting result === '', but got '{$result}')");
     session_start();
     // resume artificially suspended session
     // We could split this into a separate test, but actually, if anything leftover from above
     // contaminates the tests below, that is also a bug that we want to know about.
     $s = new Zend_Session('expireGuava');
     $s->setExpirationSeconds(5, 'g');
     // now try to expire only 1 of the keys in the namespace
     $s->g = 'guava';
     $s->p = 'peach';
     $s->p = 'plum';
     session_write_close();
     // release session so process below can use it
     sleep(6);
     // not long enough for things to expire
     exec($this->script . "expireAll {$id} expireGuava", $result);
     $result = $this->sortResult($result);
     session_start();
     // resume artificially suspended session
     $this->assertTrue($result === ';p === plum', "iteration over named Zend_Session namespace failed (result={$result})");
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:47,代码来源:SessionTest.php


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