laravel csrf_token无法识别的问题
报错提示
前端代码
<div class="container">
<form method="post" action="/data">
{{ csrf_field() }}
<input type="text" name="name">
<input type="submit" value="提交">
</form>
</div>
后端代码
Route::group(['middleware'=>'web'], function (){
Route::get('/form', function(){
return view('form');
});
Route::post('/data', function (){
return dd($_POST);
});
});
检查了session文件发现数据提交前后token值不一致
提交前
a:4:{s:6:"_token";s:40:"DOj01mDDBWNLJ11UWQ3LBgthXLPud5Lx4mCYF2pS";s:9:"_previous";a:1:{s:3:"url";s:28:"http://www.justonce.net/form";}s:9:"_sf2_meta";a:3:{s:1:"u";i:1481014874;s:1:"c";i:1481014874;s:1:"l";s:1:"0";}s:5:"flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}
提交后
a:3:{s:6:"_token";s:40:"zQOa0WiEdD9UFjKhNdHwEHwfMkAbqk3Dp5khKPC0";s:9:"_sf2_meta";a:3:{s:1:"u";i:1481014892;s:1:"c";i:1481014892;s:1:"l";s:1:"0";}s:5:"flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}
No Comments