如何使用PHP(codeigniter)启用csrf_protection的ajax帖子 [英] How to use ajax post with PHP (codeigniter) enabling csrf_protection
问题描述
我正在创建一个使用ajax.post方法发布一些数据的页面。
我正在使用codeigniter。我已启用csrf保护为真。
我收到 403(禁止)错误。
我尝试过:
CSRF配置为:
$ config ['csrf_protection'] = true;
$ config ['csrf_token_name'] ='csrf_test_name';
$ config ['csrf_cookie_name'] ='csrf_cookie_name';
$ config ['csrf_expire'] = 7200;
我试过正常发布为:
$ .post(' http:// localhost / pro352 / agent / book_service /',{service_id:service_id}, function (data){
$(' #badge')。text(data);
});
请帮帮我!
I am creating a page that posts some data as with ajax.post method. 这篇关于如何使用PHP(codeigniter)启用csrf_protection的ajax帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
config ['csrf_token_name'] ='csrf_test_name';
< blockquote> config ['csrf_cookie_name'] ='csrf_cookie_name';
I am using codeigniter. I have enabled csrf protection true.
I am getting 403 (Forbidden) error.
What I have tried:
CSRF config is :
$config['csrf_protection'] = true;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
I have tried to post normaly as :
$.post('http://localhost/pro352/agent/book_service/',{service_id:service_id},function(data){
$('#badge').text(data);
});
please help me!config['csrf_protection'] = true;
config['csrf_token_name'] = 'csrf_test_name';
config['csrf_cookie_name'] = 'csrf_cookie_name';