laravel 4:为什么支持:: header()函数没有得到指定的头? [英] laravel 4: why is Request::header() not getting the specified header?
问题描述
我试图得到一个标头值:
I'm trying to get a header value with:
支持::头('csrf_token')
不过,我在萤火,我有csrf_token设置为 baMDpF0yrfRerkdihFack1Sa9cchUk8qBzm0hK0C
头说。其实,我可以得到 csrf_token
,而不是用原始的PHP code:
though, my firebug says in the headers that I have the csrf_token set to baMDpF0yrfRerkdihFack1Sa9cchUk8qBzm0hK0C
. In fact, I can get that csrf_token
instead with a native php code:
getallheaders()可以['csrf_token']
现在的问题是我在做我的XSRF保护吗?也许存在这样的PHP code我做了一个缺陷,那我真的要使用马车laravel 4功能
Now the question is am I doing my XSRF-protection right? or maybe there is a flaw in that php code I did, that I really have to use buggy laravel 4 function
支持::头('csrf_token')
返回只不过是一片空白。我只是错过了一些东西。也许在我的Laravel 4种配置,等等?
which returns nothing but blank. And I just missed something. maybe in my Laravel 4 configurations, etc?
P.S:我用AngularJS,但也许不要紧我使用什么客户方。我有这个链接作为我的指导:<一href=\"http://stackoverflow.com/questions/18336699/how-to-send-csrf-token-inside-angularjs-form-using-laravel-api\">How使用Laravel API AngularJS形式发送里面csrf_token()?
P.S: I am using AngularJS, but maybe it does not matter what clientside I use. I have this link as my guide: How to send csrf_token() inside AngularJS form using Laravel API?
推荐答案
我通过删除csrf_token下划线_所以这将是代替crsftoken解决的问题。
I solved the problem by removing the underscore '_' in csrf_token so it would be crsftoken instead.
Request::header('csrf_token'); // Not working
Request::header('csrftoken'); // Working!
这篇关于laravel 4:为什么支持:: header()函数没有得到指定的头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!