/** * * 不设置密钥就开始使用LtCookie * @expectedException PHPUnit_Framework_Error */ public function testNoSecretKeySet() { $cookie = new LtCookie(); //不设置密钥 或者 密钥为空 $cookie->configHandle->addConfig(array("cookie.secret_key" => "")); $cookie->init(); }
<?php require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "common.inc.php"; $operation = $_REQUEST["operation"]; /** * Lotus组件初始化三步曲 */ // 1. 实例化 $cookie = new LtCookie(); // 2. 设置属性 $cookie->configHandle->addConfig(array("cookie.secret_key" => "dsds@#\$%^&*(werewt")); // 3. 调init()方法 $cookie->init(); /** * 初始化完毕,测试其效果 */ switch ($operation) { case "set": foreach ($_REQUEST["cookies"] as $cookieName => $cookieValue) { $cookie->setCookie($cookieName, $cookieValue, time() + 3600); } break; case "get": echo serialize($cookie->getCookie($_REQUEST["cookie_name"])); break; case "del": $cookie->delCookie($_REQUEST["cookie_name"]); break; }
<?php ob_start(); /** * 加载Cookie类文件 */ $lotusHome = substr(__FILE__, 0, strpos(__FILE__, "example")); include $lotusHome . "/runtime/Cookie/Cookie.php"; include $lotusHome . "/runtime/Config.php"; include $lotusHome . "/runtime/Store.php"; include $lotusHome . "/runtime/StoreMemory.php"; /** * 开始使用Cookie * php.ini需要修改为output_buffering = On */ $cookie = new LtCookie(); $cookie->setCookie('newproj', 'hello', time() + 3600); // 值为数组 $cookie->setCookie('test', array('a', 'b', 'c', 'd'), time() + 3600); if ($_COOKIE) { print_r($cookie->getCookie('newproj')); print_r($cookie->getCookie('test')); $cookie->delCookie('newproj'); $cookie->delCookie('test'); } else { echo "set cookie ...."; }
public function encrypt($seed) { return parent::encrypt($seed); }