Bad Request #400 Error On Logout ?

I suddenly noticed that I am getting a Bad Request (#400) Error on logout and a couple of other actions, which were working ok.

The exception returned is as follows:




exception 'yii\web\BadRequestHttpException' with message 'Unable to verify your data submission.' 

in /htdocs/advanced/vendor/yiisoft/yii2/web/Controller.php:109 

Stack trace: 

#0 /htdocs/advanced/vendor/yiisoft/yii2/base/Controller.php(146): yii\web\Controller->beforeAction(Object(yii\base\InlineAction)) 

#1 /htdocs/advanced/vendor/yiisoft/yii2/base/Module.php(460): yii\base\Controller->runAction('logout', Array) 

#2 /htdocs/advanced/vendor/yiisoft/yii2/web/Application.php(82): yii\base\Module->runAction('site/logout', Array) 

#3 /htdocs/advanced/vendor/yiisoft/yii2/base/Application.php(368): yii\web\Application->handleRequest(Object(yii\web\Request)) 

#4 /htdocs/advanced/frontend/web/index.php(17): yii\base\Application->run() 

#5 {main}



My SiteController logout action is as follows:




    public function actionLogout()

    {        

        Yii::$app->user->logout();

        return $this->goHome();

    }



What else can I check to find the cause of the problem?

Is there a config setting somewhere I need to check?

See UPGRADE instructions:

Thank you! This resolved my problem, which was apparently caused after running a composer update. By the way, do you know if this is a permanent solution? Just curious, as Yii2 is getting closer and closer to a stable release.

Yes, this change is quite permanent, you always have to include CSRF tokens in layout manually. This is of course already included in the applciation templates.

Hi guys!

I use CSRF to yii version 2.0.4, and PHP version 5.4.45, but for some reason I have this problem has disappeared.

Another such error go

Showing {begin, number} - {end, number} of {totalCount, number} {totalCount, plural, one {item} other {items}}.

on the local server (Open Server) everything works fine