小编Bnd*_*ndr的帖子

设置配置项(CSRF)在Codeigniter中不起作用

我只想在几个控制器中打开csrf保护,所以我有

function __construct() {

    parent::__construct();
    $this->load->library('form_validation');        
    $this->load->library('tank_auth');
    $this->load->helper(array('form', 'url'));
    $this->load->model('user_model', '', true);

    $this->config->set_item('csrf_protection', TRUE);

}
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用,尽管当我在页面上执行var_dump($ this-> config)时,它表明csrf_protection为TRUE,但未设置cookie,并且窗体具有一个没有值的隐藏字段

<input type="hidden" name="ci_csrf_token" value="" />

Csrf令牌名称和cookie名称都已设置,使用form_open()调用表单。

任何帮助将非常感激。

更新:由于安全类构造中的这一行,因此从2.1.1版本开始这是不可能的if (config_item('csrf_protection') === TRUE) {

安全类在控制器之前初始化,因此自然而然地改变了控制器中的配置项不会影响它。

php config codeigniter csrf

5
推荐指数
1
解决办法
2856
查看次数

Golang相当于pythons __getattr __()或__call __()

我想在运行时操作结构.

例如,我有一个结构:

type Item struct {
 SomeField string
}
Run Code Online (Sandbox Code Playgroud)

是否可以在运行时添加字段?或尚未定义的访问属性.像pythons __getattr__() or __call__(这样的东西)所以我可以动态控制访问的字段/方法.

例如,做一些 Item.DynamicField or Item.DynamicMethod()我不完全知道将要访问/调用的字段或方法的地方,所以我无法静态定义它.

也许我在Reflect包中遗漏了一些东西?

谢谢.

python generics dynamic go

2
推荐指数
2
解决办法
2107
查看次数

标签 统计

codeigniter ×1

config ×1

csrf ×1

dynamic ×1

generics ×1

go ×1

php ×1

python ×1