php - 如何在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();?>">
解决方案
设置$config['csrf_protection'] = TRUE;
在application/config.php
推荐阅读
- python-3.x - Pandas 如何将 2 列数据框转换为系列?
- sql - 今年每个产品的转化率是多少
- python - 如何在不使用双指针的情况下从链表中删除最后一个节点
- wordpress - 我可以选择“视频”帖子格式并在帖子底部显示视频吗?
- javascript - 更新网页以反映 CRUD 应用程序中已删除的数据,而无需硬刷新
- android - 从 Xamarin Android 中的自定义渲染器引用 RelativeLayout 时出错
- informatica - 如何在 informatica 中编写 IIF() 函数
- python - BeautifulSoup 在第一页之后不起作用
- git - 我可以使用 xdotool 键“ctrl+x”在运行 shell 脚本时从 git 拉出时退出 nano 吗?
- javascript - 如何附加10
我用 for 循环创建到父级?