错误在codeigniter中启用CSRF保护TRUE

时间:2017-02-16 11:35:57

标签: php codeigniter

我的应用程序中有一个表单,出于安全原因,我需要在config.php中添加An Error Was Encountered The action you have requested is not allowed. 。但是在添加之后我的表单无法提交并向我显示这样的错误。

$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();

谁能告诉我,如何解决这个问题?

以下是我的config.php中的CSRF代码

        mAdapter.notifyDataSetChanged();
        mViewPager.setAdapter(mAdapter);

1 个答案:

答案 0 :(得分:1)

如果您打开CSRF,请确保使用form_open函数打开表单标记,否则您将看到错误。

以下是此信息的相关链接 -
https://www.codeigniter.com/user_guide/libraries/security.html
Codeigniter CSRF - how does it work
CodeIgniter use CSRF protection only in some pages