Yii2 - Bad Request (#400) Unable to verify your data submission

yii2 unable to verify your data submission
please contact us if you think this is a server error thank you
yii2 disable csrf token
oops we were unable to verify your csrf token

My yii2 application was working fine till yesterday however today on submiting form it is showing error. "Bad Request (#400) Unable to verify your data submission.".

I found many such questions on stackoverflow, where people are suggesting to disable csrf validation i tried disabling csrf validation also. i even updated my composer still it is not working.

please suggest any other possible solution.

This is my form code :-

<h2>Open an Account</h2>
                  <?php
                    $form = ActiveForm::begin([
                            'id' => 'live-account-form',
                            'enableClientValidation' => true,
                            'fieldConfig' => [
                                'template' => '{input}{error}',
                                'options' => [
                                    'tag' => false,
                                ]
                            ],
                            'options' => [
                                'class' => 'form-horizontal'
                            ]
                        ]);
                  ?>

                  <div class="form-group">
                    <label for="signupform-first_name" class="col-sm-3 control-label">First Name*</label>
                    <div class="col-sm-9 field-signupform-first_name">
                        <?= $form->field($model, 'first_name')->textInput(['placeholder' => "Enter First Name"]) ?>  

                    </div>
                  </div> 

                  <div class="form-group">
                    <label for="singupform-last_name" class="col-sm-3 control-label">Last Name*</label>
                    <div class="col-sm-9 field-signupform-last_name">
                        <?= $form->field($model, 'last_name')->textInput(['placeholder' => 'Enter Last Name']) ?> 
                    </div>
                  </div>   

                  <div class="form-group">
                    <label for="signupform-email" class="col-sm-3 control-label">Email*</label>
                    <div class="col-sm-9 field-signupform-email">
                        <?= $form->field($model, 'email')->textInput(['placeholder' => "Enter Email Address"]) ?>
                    </div>
                  </div>

                  <div class="form-group">
                    <label for="signupform-country" class="col-sm-3 control-label">Country*</label>
                    <div class="col-sm-9 field-signupform-country">
                        <?= $form->field($model, 'country')->dropDownList(
                            ArrayHelper::map(PhCountry::find()->all(), 'intid', 'country_name'),
                            [
                                'prompt' => 'Select Country',
                                'onchange' => '$( "select#signupform-country_code" ).html("showLoading");
                                    $.get( "index.php/site/fetch-country-code?id='.'"+$(this).val(), 
                                    function(data) {
                                        $( "#signupform-country_code" ).val(data);
                                    });'
                            ]
                        ) ?>
                    </div>
                  </div>

                  <div class="form-group">
                      <label class="col-sm-3 control-label">Phone Number*</label>
                      <div class="col-sm-9 phone-number-div">
                        <div>
                        <?= $form->field($model, 'country_code')->textInput(['placeholder' => 'Code', 'class' => 'country-code form-control']) ?>
                        </div>
                        <div class="field-signupform-phone">
                        <?= $form->field($model, 'phone')->textInput(['placeholder' => 'Enter Phone Number', 'class' => 'enter-phone-number form-control']) ?>
                        </div>
                      </div>
                    </div>

                    <button type="submit" class="btn btn-default">Create Account</button>
                  <?php
                    ActiveForm::end();
                  ?>

and this is my action code inside controller:-

public function actionIndex()
{
    Yii::$app->controller->enableCsrfValidation = false;
    $model = new SignupForm();
    if ($model->load(Yii::$app->request->post())) {
        //print_r($model);
        if ($user = $model->signup()) {
            if($model->sendRegistrationEmail($user)) {
                Yii::$app->session->setFlash('emailSent', 'An email containing confirmation link is sent to your email Address.');
                if (Yii::$app->getUser()->login($user)) {
                    return $this->goHome();
                }    
            } 
        }
        //exit;
    }

    return $this->render('index', [
        'model' => $model,
    ]);
}

Use this :

public function beforeAction($action) 
{ 
    $this->enableCsrfValidation = false; 
    return parent::beforeAction($action); 
}

Do not disable CSRF

"Bad Request (#400): Unable to verify your data submission" on , Install basic yii2 app composer create-project --prefer-dist "Bad Request (#400​): Unable to verify your data submission" on unmodified  I am suddenly getting the "Unable to verify your data submission" on a $.ajax() call that was working fine. I haven't changed the config or the $.ajax() call. I just ran a "composer update", and I cleared the cookies in my browser. If I set enableCsrfValidation to FALSE it works fine. I'm just getting my feet wet with Yii2 and composer.


You can use below configuration in your main config file to globally disable csrf validation in whole application.

$config = [
    'components' => [
        'request' => [
            'enableCsrfValidation' => false,
        ],
    ],
];

HTTP 400, My Yii 2 application was progressing well until I received an unusual error about a bad HTTP request. The error is: HTTP 400 Unable to verify your data submission. We are happy to help you on the support forum, on IRC (#yii on Strangely, this Bad Request error only happened in certain server. I tested  yii2 Unable to verify your data submission. Bad Request (#400) Unable to verify your data submission Looks like your session id changes. Check if the value of


There are two ways you can try. First increase post_max_size size in php.ini. Second run composer update and clear cookie as follow: - composer self-update - composer update - clear cookie

Bad Request (#400) Unable to verify your data submission, Bad Request (#400) Unable to verify your data submission · Yii 2.0 · General Discussions · tousif1988 (Tousif1988) September 5, 2018, 5:44pm  Uploading 1 File works fine, POST data includes _csrf and form model data. body includes required file data. multiple files upload from the same form fails with 400 error, Post data missing _csrf token AND model data. Body does contain multipart file data including _csrf token but it is different to the session _csrf token.


I'm using the advanced template and ran into this issue. After much head banging I noticed the _csrf meta tag used in yii's baked in forms was named "_csrf-frontend" (on the frontend of course). Also the request cookie was named the same.

Provided the header in your layout is registering the meta tag

<?php $this->registerCsrfMetaTags() ?>

Submit _csrf with the same name as the meta tag in your ajax. Yii provides helper for this also

<?=Yii::$app->request->csrfParam?>

Quick example:

var postData = {
   someparam : somevalue,
   '<?=Yii::$app->request->csrfParam?>': '<?=Yii::$app->request->getCsrfToken()?>'
}

$.ajax({
    type: 'post',
    data: postData,
    url: dataURL,
})

Helpful info here: https://yii2-cookbook-test.readthedocs.io/csrf/

Yii 2.0 Error "Unable to verify your data submission" - Newest , Bad Request (#400) Unable to verify your data submission. after analysis we found, it because form data not have csrf value, Yii 2.0 enabled csrf  Yii2 Advanced Setup - Backend Login Bad Request (#400) - Unable to verify your data submission. #73 cicsolutions opened this issue Feb 21, 2015 · 3 comments


Csrf, Bad Request (#400) Unable to verify your data submission. This is because for every request Yii generates a special unique token that you have to send with your  Bad Request (#400): Unable to verify your data submission. calling the ajax POST request along with your data you should use the yii.js Yii2 ajax bad request


Why get Unable to verify your data submission error in Yii2?, But one issue I got stuck at is that after user log-in the ajax call didn't work and gave Error: Bad Request (#400): Unable to verify your data submission. I get this​  In Yii 2.0 Framework Dev, when post data to controller will get this kind error Bad Request (#400) Unable to verify your data submission. after analysis we found, it because form data not have csrf value, Yii 2.0 enabled csrf check as default, so we can find the follow hidden input in normal Yii 2.0 form


Craft 3 installation issue on account creation, I want to create my account but the next button is doing nothing. I get an error 400 "Bad Request // Unable to verify your data submission. data submission. in /​home/MyWebsite/www/vendor/yiisoft/yii2/web/Controller.php:166  Bad Request (#400) Unable to verify your data submission. The above error occurred while the Web server was processing your request. Please contact us if you think this is a server error.