【问题标题】:Laravel 4 tokenmismatch on Chrome only仅在 Chrome 上的 Laravel 4 令牌不匹配
【发布时间】:2014-02-19 17:31:30
【问题描述】:

我使用 csrf,它在 safari 和 firefox 中运行良好(可以显示 POST 页面),但只能在 chrome 中获得 TokenMismatchException?有谁知道是什么问题?我试图清除捕获物,但它保持不变。

Routes.php

/*
| Unauthenticated group
*/
Route::group(array('before' => 'guest'), function(){

/*
| CSRF protection group
*/
Route::group(array('before' => 'csrf'), function(){

    /*
    | Create Account (POST)
    */
    Route::post('/account/create', array(
        'as' => 'account-create-post',
        'uses' => 'AccountController@postCreate'
    ));
});

/*
| Create Account (GET)
*/
Route::get('/account/create', array(
    'as' => 'account-create',
    'uses' => 'AccountController@getCreate'
    ));
});

AccountController.php

<?php
class AccountController extends BaseController{

public function getCreate(){
     return View::make('account.create');

}

public function postCreate(){
    return 'Hello.';
}
}

create.blade.php

@extends('layouts.master')

@section('content')
<form action="{{ URL::route('account-create-post') }}" method="post">
    <input type="submit" value="Create account">
    {{ Form::token() }}
</form>
@stop

【问题讨论】:

  • 仅在 chrome 上也发生在我身上,正在寻找解决方案:(
  • 我的只是我没有在我的 chrome 中保留任何 cookie.. 所以会话令牌每次都更改

标签: php google-chrome laravel-4 token csrf


【解决方案1】:

解决了这个问题。因为我设置阻止所有站点设置任何数据(cookies),所以它不保留令牌.. 现在我已更改为允许设置本地数据。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-24
    • 1970-01-01
    • 2020-07-08
    • 2016-12-10
    • 2016-09-20
    • 2020-01-20
    • 2017-05-23
    • 2016-12-06
    相关资源
    最近更新 更多