首页 > 解决方案 > 如何在codeigniter 3中使用csrf

问题描述

我正在使用 codeigniter 3 我想在我的项目中使用 csrf 当我为 true csrf_protection 时它会显示一个错误,例如(不允许您请求的操作。)当我对 csrf_protection 执行错误时,当我将其设为 true 时,该值为空此错误显示(不允许您请求的操作。)我如何使用 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();

在我看来,我正在使用这个

<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">

标签: phpcodeigniter

解决方案


设置$config['csrf_protection'] = TRUE;application/config.php


推荐阅读