本文整理汇总了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');
}
示例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