简体   繁体   English

如何在Codeigniter 3中使用CSRF

[英]How to use csrf in codeigniter 3

I am using codeigniter 3 i want to use csrf in my project when i true csrf_protection it show an error like (the action you have requested is not allowed.) when i do false of csrf_protection the value is empty when i make it ture then the this error shows(the action you have requested is not allowed.) how can i use csrf thanks in advance. 我正在使用codeigniter 3,当我为true csrf_protection时,我想在我的项目中使用csrf,它显示错误消息(不允许执行您要求的操作。)当我对csrf_protection做错误时,将其设为true时该值为空,则此错误显示(不允许您执行请求的操作。)我如何提前使用CSRF。 config.php 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();

in my view i am using this 在我看来,我正在使用这个

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

set $config['csrf_protection'] = TRUE; set $config['csrf_protection'] = TRUE; in application/config.php application/config.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM