Answers.Body: <p>After discussions on Craft Slack and with Brandon on GitHub it was noticed that one component in Gulp had a path set to compile some files out into a <code>/web</code> directory, even after I'd changed my project to use the <code>/public</code> directory instead.</p>
  
  <p>So I think Craft was getting confused between <code>/public</code> and <code>/web</code>.</p>
  
  <p>This also lead to the <code>/public</code> directory having an out of date <code>/cpresources</code> directory and the login page was unable to match up the new CRSF token field to the set cookie without the javascript resources.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-04T09:53:27.533Z
Answers.LastActivityDate: 2018-09-04T09:53:27.533Z
Answers.UserDisplayName: Jay
Answers.Body: <p>I just had this issue and I found that I caused it by setting the <code>defaultCookieDomain</code> to something else, than where my Craft website was running. The effect was that the CSRF cookie was never sent to my server when logging in, so CSRF failed. </p>
  
  <p>Removing/updating the <code>defaultCookieDomain</code> setting from/in <code>general.php</code> file should fix the issue.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-07T02:33:30.993Z
Answers.LastActivityDate: 2019-08-07T02:33:30.993Z
Answers.UserDisplayName: Jan Klan
Answers.Body: <p>I haven't seen this particular issue but generally I've found that from time to time MAMP doesn't like running Craft in CGI mode, i.e. with different PHP versions per host.</p>
  
  <p>Try switching it to module mode (under the PHP tab of MAMP Pro). If that works, then try reverting to CGI mode. You may find it continues to work.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-04T09:25:38.993Z
Answers.Text: Yeah, I've had this before, too. I'm always running in Module mode. Cheers
Answers.UserDisplayName: Jay
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-03T16:09:38.107Z
Answers.LastActivityDate: 2018-09-03T16:09:38.107Z
Answers.UserDisplayName: foamcow
Body: <p>I have just tried to log into an old local Craft 3 project that hasn't been worked on in a few months and I'm getting the following:</p>
  
  <p><code>HTTP 400 – Bad Request – yii\web\BadRequestHttpException</code></p>
  
  <p><code>Unable to verify your data submission.</code></p>
  
  <pre><code>yii\web\BadRequestHttpException: Unable to verify your data submission. in /Users/user/Development/project/build/vendor/yiisoft/yii2/web/Controller.php:166
  Stack trace:
  #0 /Users/user/Development/project/build/vendor/craftcms/cms/src/web/Controller.php(82): yii\web\Controller-&gt;beforeAction(Object(yii\base\InlineAction))
  #1 /Users/user/Development/project/build/vendor/yiisoft/yii2/base/Controller.php(155): craft\web\Controller-&gt;beforeAction(Object(yii\base\InlineAction))
  #2 /Users/user/Development/project/build/vendor/craftcms/cms/src/web/Controller.php(103): yii\base\Controller-&gt;runAction('login', Array)
  #3 /Users/user/Development/project/build/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller-&gt;runAction('login', Array)
  #4 /Users/user/Development/project/build/vendor/craftcms/cms/src/web/Application.php(282): yii\base\Module-&gt;runAction('users/login', Array)
  #5 /Users/user/Development/project/build/vendor/craftcms/cms/src/web/Application.php(538): craft\web\Application-&gt;runAction('users/login', Array)
  #6 /Users/user/Development/project/build/vendor/craftcms/cms/src/web/Application.php(266): craft\web\Application-&gt;_processActionRequest(Object(craft\web\Request))
  #7 /Users/user/Development/project/build/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application-&gt;handleRequest(Object(craft\web\Request))
  #8 /Users/user/Development/project/build/public/index.php(42): yii\base\Application-&gt;run()
  #9 {main}
  </code></pre>
  
  <p>The front end of the site fine, the login page at <code>/admin</code> works and I've restarted MAMP multiple times. I have also locally run <code>composer update</code> in case there were any issues with my packages.</p>
  
  <p>But nothing seems to make it want to successfully sign me in.</p>
  
  <p>UPDATE:</p>
  
  <p>After more research, a lot of people have had their issues like this resolved by clearing the cache of their browser. I have tried this in three separate browsers all to no improvement.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-02T23:18:24.233Z
Comments.Text: Are you in a load-balanced web server environment?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-03T07:00:34.130Z
Comments.Text: No, it’s just a local MAMP setup.
Comments.UserDisplayName: Jay
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-03T12:05:25.013Z
Comments.Text: Did you try removing the cookies as well? Maybe it's related to an outdated cookie...
Comments.UserDisplayName: kant312
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-03T13:31:31.937Z
Comments.Text: @kant312 I removed all browser data. Everything from cookies to history.
Comments.UserDisplayName: Jay
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-29T15:00:21.090Z
Comments.Text: Thank you, Clearing my cache worked!
Comments.UserDisplayName: mateostabio
Tags: <control-panel><admin><login><yii>
Title: 400 error logging into local Craft 3 project
ThreadText: # 400 error logging into local Craft 3 project
  
  (Asked by: username_0 on 2018-08-22)
  
  I have just tried to log into an old local Craft 3 project that hasn't been worked on in a few months and I'm getting the following:
  
  `HTTP 400 – Bad Request – yii\web\BadRequestHttpException`
  
  `Unable to verify your data submission.`
  
  ```
  yii\web\BadRequestHttpException: Unable to verify your data submission. in /Users/user/Development/project/build/vendor/yiisoft/yii2/web/Controller.php:166
  Stack trace:
  #0 /Users/user/Development/project/build/vendor/craftcms/cms/src/web/Controller.php(82): yii\web\Controller->beforeAction(Object(yii\base\InlineAction))
  #1 /Users/user/Development/project/build/vendor/yiisoft/yii2/base/Controller.php(155): craft\web\Controller->beforeAction(Object(yii\base\InlineAction))
  #2 /Users/user/Development/project/build/vendor/craftcms/cms/src/web/Controller.php(103): yii\base\Controller->runAction('login', Array)
  #3 /Users/user/Development/project/build/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('login', Array)
  #4 /Users/user/Development/project/build/vendor/craftcms/cms/src/web/Application.php(282): yii\base\Module->runAction('users/login', Array)
  #5 /Users/user/Development/project/build/vendor/craftcms/cms/src/web/Application.php(538): craft\web\Application->runAction('users/login', Array)
  #6 /Users/user/Development/project/build/vendor/craftcms/cms/src/web/Application.php(266): craft\web\Application->_processActionRequest(Object(craft\web\Request))
  #7 /Users/user/Development/project/build/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
  #8 /Users/user/Development/project/build/public/index.php(42): yii\base\Application->run()
  #9 {main}
  
  ```
  
  The front end of the site fine, the login page at `/admin` works and I've restarted MAMP multiple times. I have also locally run `composer update` in case there were any issues with my packages.
  
  But nothing seems to make it want to successfully sign me in.
  
  UPDATE:
  
  After more research, a lot of people have had their issues like this resolved by clearing the cache of their browser. I have tried this in three separate browsers all to no improvement.
  
  **Tags:** control-panel, admin, login, yii
  
  > **Comments:**
  > **username_1**: Are you in a load-balanced web server environment?  
  > **username_0**: No, it’s just a local MAMP setup.  
  > **username_2**: Did you try removing the cookies as well? Maybe it's related to an outdated cookie...  
  > **username_0**: @username_2 I removed all browser data. Everything from cookies to history.  
  > **username_3**: Thank you, Clearing my cache worked!  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2018-09-04. Score: 1 | Accepted answer
  
  After discussions on Craft Slack and with Brandon on GitHub it was noticed that one component in Gulp had a path set to compile some files out into a `/web` directory, even after I'd changed my project to use the `/public` directory instead.
  
  So I think Craft was getting confused between `/public` and `/web`.
  
  This also lead to the `/public` directory having an out of date `/cpresources` directory and the login page was unable to match up the new CRSF token field to the set cookie without the javascript resources.
  
  
  ---
  
  ### Answer by username_4 on 2019-08-07. Score: 2
  
  I just had this issue and I found that I caused it by setting the `defaultCookieDomain` to something else, than where my Craft website was running. The effect was that the CSRF cookie was never sent to my server when logging in, so CSRF failed.
  
  Removing/updating the `defaultCookieDomain` setting from/in `general.php` file should fix the issue.
  
  
  ---
  
  ### Answer by username_5 on 2018-09-03. Score: 2
  
  I haven't seen this particular issue but generally I've found that from time to time MAMP doesn't like running Craft in CGI mode, i.e. with different PHP versions per host.
  
  Try switching it to module mode (under the PHP tab of MAMP Pro). If that works, then try reverting to CGI mode. You may find it continues to work.
  
  > **Comments:**
  > **username_0**: Yeah, I've had this before, too. I'm always running in Module mode. Cheers  
  
  ---
  
  