bistro/session

会话抽象库

0.1.0 2013-02-20 20:04 UTC

This package is not auto-updated.

Last update: 2024-09-22 02:53:37 UTC


README

PHP 5.3+ 的会话库。允许使用不同的存储引擎。

引擎

库中包含 2 个存储引擎。

本地

此驱动程序使用 PHP 本地的 $_SESSION 数组来处理会话数据。

$session = new \Bistro\Session\Native;

$timeout = $session->get('timeout');

if ($timeout === null)
{
	$session->set('timeout', time() + 43200);
}

MockArray

还有一个 MockArray 存储引擎,可以帮助进行会话数据的单元测试。MockArray 会话不会在 "请求" 之间保存状态。

$data = array(
	'test' => "Session data",
	'goes' => "Here"
)

$session = new \Bistro\Session\MockArray($data);

$session->has('test'); // true
$missing = $session->get('missing'); // null

存储接口

检查 \Bistro\Session\Session 以获取可用于会话存储引擎的所有公共方法。