當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。