【发布时间】:2017-07-05 11:57:26
【问题描述】:
我的应用程序中有一个表单,出于安全原因,我需要在我的config.php 中添加csrf_protection = TRUE。但是在添加这个之后,我的表单无法提交并向我显示这样的错误。
An Error Was Encountered
The action you have requested is not allowed.
谁能告诉我,如何解决这个问题?
下面是我的 config.php 中的 CSRF 代码
$config['csrf_protection'] = TRUE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
【问题讨论】:
-
您的表单中有 CSRF 令牌吗?如果您使用 CI 的
form_open(),它会自动添加它。否则,您可以使用<input type="hidden" name="<?=$csrf['name'];?>" value="<?=$csrf['hash'];?>" />手动添加它。 See here.
标签: php codeigniter