當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfSessionStorage::write方法代碼示例

本文整理匯總了PHP中sfSessionStorage::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfSessionStorage::write方法的具體用法?PHP sfSessionStorage::write怎麽用?PHP sfSessionStorage::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfSessionStorage的用法示例。


在下文中一共展示了sfSessionStorage::write方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getFavorites

 /**
  * @return ArrayObject
  */
 public static function getFavorites()
 {
     $session = new sfSessionStorage();
     if ($session->read('favorites') === null) {
         $session->initialize(array('session_cookie_lifetime' => 2592000));
         $session->write('favorites', new ArrayObject(array()));
     }
     return $session->read('favorites');
 }
開發者ID:HHirano,項目名稱:TEST100,代碼行數:12,代碼來源:Utils.php

示例2: dirname

require_once dirname(__FILE__) . '/../../bootstrap/functional.php';
ob_start();
$_test_dir = realpath(dirname(__FILE__) . '/../../');
require_once $_test_dir . '/../lib/vendor/lime/lime.php';
sfConfig::set('sf_symfony_lib_dir', realpath($_test_dir . '/../lib'));
$t = new lime_test(8, new lime_output_color());
// initialize the storage
try {
    $storage = new sfSessionStorage();
    $t->pass('->__construct() does not throw an exception when not provided with options');
} catch (InvalidArgumentException $e) {
    $t->fail('->__construct() Startup failure');
}
$storage = new sfSessionStorage();
$t->ok($storage instanceof sfStorage, '->__construct() is an instance of sfStorage');
$storage->write('test', 123);
$t->is($storage->read('test'), 123, '->read() can read data that has been written to storage');
// regenerate()
$oldSessionData = 'foo:bar';
$key = md5($oldSessionData);
$storage->write($key, $oldSessionData);
$session_id = session_id();
$storage->regenerate(false);
$t->is($storage->read($key), $oldSessionData, '->regenerate(false) regenerated the session with a different session id - this class by default doesn\'t regen the id');
$t->isnt(session_id(), $session_id, '->regenerate(false) regenerated the session with a different session id');
$storage->regenerate(true);
$t->is($storage->read($key), $oldSessionData, '->regenerate(true) regenerated the session with a different session id and destroyed data');
$t->isnt(session_id(), $session_id, '->regenerate(true) regenerated the session with a different session id');
$storage->remove($key);
$t->is($storage->read($key), null, '->remove() removes data from the storage');
// shutdown the storage
開發者ID:mediasadc,項目名稱:alba,代碼行數:31,代碼來源:sfSessionStorageTest.php


注:本文中的sfSessionStorage::write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。