我通過FuelPHP文檔搜索到但未找到cookie前綴配置。FuelPHP無法設置cookie前綴
我用這段代碼擴展了fuel/app/classes/extension/cookie.php中的類。
namespace Extension;
class Cookie extends \Fuel\Core\Cookie
{
private static $config = array(
'expiration' => 0,
'path' => '/',
'domain' => null,
'secure' => false,
'http_only' => false,
'prefix' => '', // added prefix to cookie.
);
public static function _init()
{
static::$config = array_merge(static::$config, \Fuel\Core\Config::get('cookie', array()));
}
public static function set($name, $value, $expiration = null, $path = null, $domain = null, $secure = null, $http_only = null)
{
// add prefix to cookie.
$prefix = '';
is_null($prefix) and $prefix = static::$config['prefix'];
$name = $prefix . $name;
parent::set($name, $value, $expiration, $path, $domain, $secure, $http_only);
}
}
當我調用\ Extension \ Cookie :: set('name','value');它返回錯誤。
Cannot access private property Extension\Cookie::$config
COREPATH/classes/cookie.php @ line 92
Line 92 is_null($expiration) and $expiration = static::$config['expiration'];
如何將cookie類擴展爲在set,get和delete上自動添加名稱前綴?
現在我必須擴展和複製整套功能並修改它。我不喜歡這種方式,因爲當FuelPHP更新源代碼時,我必須再次複製和粘貼。 – vee