获得codeigniter CSRF令牌没有一种形式? [英] Getting Codeigniter CSRF token without a form?
本文介绍了获得codeigniter CSRF令牌没有一种形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的网站上启用了CSRF保护,但CSRF令牌被放置在一个隐藏字段的唯一时间是当 form_close()
被使用。我通过AJAX发布数据需要发送的CSRF以及以prevent 500错误。
I have CSRF protection enabled on my site, but the only time the CSRF token is placed in a hidden field is when form_close()
is used. I am posting data via ajax and need to send the CSRF as well to prevent the 500 errors.
我觉得有一种方法来明确地嵌入CSRF令牌进入页面,但我似乎无法找到它。
I thought there was a way to explicitly embed the CSRF token into the page, but I can't seem to find it.
我怎样才能获得CSRF令牌时没有网页?
How can I get the CSRF token when there isn't a form on the page?
推荐答案
您可以通过安全等级得到CSRF标记名称和值:
You can get the CSRF token name and value via the security class:
$this->security->get_csrf_hash();
$this->security->get_csrf_token_name();
这篇关于获得codeigniter CSRF令牌没有一种形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文