laravel 5 csrf_token值为空 [英] laravel 5 csrf_token value is Empty

查看:653
本文介绍了laravel 5 csrf_token值为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么laravel 5 csrf_token值始终为空?

Why laravel 5 csrf_token value is empty always ?

如何获取令牌值?

我尝试过

  {!! csrf_token !!} , {{ csrf_token }} and 
  {{ Form::open() }} ....{{ Form::close() }}

我的输出

  <input type="hidden" name="_token"></input>

推荐答案

这是因为您没有使用Web组中间件. Laravel非常聪明,知道如果您不使用该组,则不需要令牌.

It's because you're not using the web group middleware. Laravel is smart enough to know that if you're not using that group a token is not necessary.

尝试在Route::group(['middleware' => 'web'] ...内移动路线,并告诉我们:)

Try moving your route inside the Route::group(['middleware' => 'web'] ... and tell us about it :)

来源:我不久前犯了同样的错误.

Source: I made the same mistake not too long ago.

这篇关于laravel 5 csrf_token值为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆