【问题标题】:How to use csrf in codeigniter 3如何在codeigniter 3中使用csrf
【发布时间】:2018-07-31 09:37:07
【问题描述】:

我正在使用 codeigniter 3 我想在我的项目中使用 csrf 当我为 true csrf_protection 时它会显示一个错误,例如(不允许您请求的操作。)当我对 csrf_protection 执行错误时,当我创建它时该值为空ture 然后这个错误显示(您请求的操作是不允许的。)我如何使用 csrf 提前谢谢。 config.php

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

【问题讨论】:

  • 只要使用form_open()函数,它就会为你创建表单和隐藏输入
  • nothing word use this form_open() when use $config['csrf_protection'] = TRUE;而不是在 FALSE teken 值为空时显示错误

标签: php codeigniter


【解决方案1】:

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

【讨论】:

  • @shahid 您介意发布错误以便我们提供帮助吗?
猜你喜欢
  • 2018-01-21
  • 2016-07-14
  • 1970-01-01
  • 2015-12-01
  • 2021-06-25
  • 1970-01-01
  • 2015-07-06
  • 1970-01-01
  • 2015-06-12
相关资源
最近更新 更多