Body: <p>I copied my entire existing install on a new staging server for some developmental work. Right now the <code>craft/config/db.php</code> file has not been changed and it is still connected to the production database. </p>
  
  <p>The website loads fine on the dev server but I cannot login to the Craft admin. When I enter my login credentials, I get the following error in my chrome web console</p>
  
  <blockquote>
    <p>Failed to load resource: the server responded with a status of 400 (Bad Request) /index.php?p=admin/actions/users/login</p>
  </blockquote>
  
  <p>When I try to load the above URL (mydomain.com/index.php?p=admin/actions/users/login), I get a 404 page not found error. </p>
  
  <p>The <code>craft/config/general.php</code> config file has the correct config for the dev server as far as I can tell. What am I missing here?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T18:15:38.083Z
Comments.Text: You won't be able to load `mydomain.com/index.php?p=admin/actions/users/login` directly in a browser because it's looking for a POST request. Can you enable devMode, reproduce the 400 Bad Request error, then edit the original question to share the whole stack trace?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T18:44:30.760Z
Comments.Text: So I find the relevant portion in craft.log causing this `2017/06/09 18:41:08 [error] [exception.Craft\HttpException.400] Craft\HttpException: The CSRF token could not be verified. in /home/forge/dev.anstrex.info/craft/app/services/HttpRequestService.php:1337
  2017/06/09 18:41:08 [trace] [system.CModule] Loading "errorHandler" application component
  in /home/forge/dev.anstrex.info/craft/app/etc/errors/ErrorHandler.php (281)`.
Comments.UserDisplayName: hvs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T18:45:46.130Z
Comments.Text: Also a phperrors.log file is generated that shows `[09-Jun-2017 18:41:08 UTC] PHP Warning:  Declaration of Craft\UserSessionService::login($username, $passwo
  rememberMe = false) should be compatible with CWebUser::login($identity, $duration = 0) in /home/forge/dev
  rex.info/craft/app/services/UserSessionService.php on line 17
  [09-Jun-2017 18:41:08 UTC] PHP Warning:  Declaration of Craft\UserSessionService::afterLogin() should be c
  ible with CWebUser::afterLogin($fromCookie) in /home/forge/dev.anstrex.info/craft/app/services/UserSession
  ce.php on line 17`
Comments.UserDisplayName: hvs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T22:20:12.640Z
Comments.Text: The first error is the important one... do you have the enableCsrfProtection config setting enabled? Try disabling it on staging and see if that helps.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T22:30:37.383Z
Comments.Text: I had enableCsrfProtection enabled for all domains(*). That was not the issue. While looking at the config file I realised that I had `defaultCookieDomain => mydomain.com` where as my staging server does not share that domain name. So after removing that entry from general.config, everything is working. Thanks for your help
Comments.UserDisplayName: hvs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-09T22:31:14.580Z
Comments.Text: Glad you got it sorted!  Would you mind adding that as an official answer in case someone runs into it?
Comments.UserDisplayName: Brad Bell
Tags: <error-message><admin><login>
Title: Problem cloning existing Craft instance on staging
ThreadText: # Problem cloning existing Craft instance on staging
  
  (Asked by: username_0 on 2017-06-09)
  
  I copied my entire existing install on a new staging server for some developmental work. Right now the `craft/config/db.php` file has not been changed and it is still connected to the production database.
  
  The website loads fine on the dev server but I cannot login to the Craft admin. When I enter my login credentials, I get the following error in my chrome web console
  
  > Failed to load resource: the server responded with a status of 400 (Bad Request) /index.php?p=admin/actions/users/login
  
  When I try to load the above URL (mydomain.com/index.php?p=admin/actions/users/login), I get a 404 page not found error.
  
  The `craft/config/general.php` config file has the correct config for the dev server as far as I can tell. What am I missing here?
  
  **Tags:** error-message, admin, login
  
  > **Comments:**
  > **username_1**: You won't be able to load `mydomain.com/index.php?p=admin/actions/users/login` directly in a browser because it's looking for a POST request. Can you enable devMode, reproduce the 400 Bad Request error, then edit the original question to share the whole stack trace?  
  > **username_0**: So I find the relevant portion in craft.log causing this `2017/06/09 18:41:08 [error] [exception.Craft\HttpException.400] Craft\HttpException: The CSRF token could not be verified. in /home/forge/dev.anstrex.info/craft/app/services/HttpRequestService.php:1337 2017/06/09 18:41:08 [trace] [system.CModule] Loading "errorHandler" application component in /home/forge/dev.anstrex.info/craft/app/etc/errors/ErrorHandler.php (281)`.  
  > **username_0**: Also a phperrors.log file is generated that shows `[09-Jun-2017 18:41:08 UTC] PHP Warning:  Declaration of Craft\UserSessionService::login($username, $passwo rememberMe = false) should be compatible with CWebUser::login($identity, $duration = 0) in /home/forge/dev rex.info/craft/app/services/UserSessionService.php on line 17 [09-Jun-2017 18:41:08 UTC] PHP Warning:  Declaration of Craft\UserSessionService::afterLogin() should be c ible with CWebUser::afterLogin($fromCookie) in /home/forge/dev.anstrex.info/craft/app/services/UserSession ce.php on line 17`  
  > **username_1**: The first error is the important one... do you have the enableCsrfProtection config setting enabled? Try disabling it on staging and see if that helps.  
  > **username_0**: I had enableCsrfProtection enabled for all domains(*). That was not the issue. While looking at the config file I realised that I had `defaultCookieDomain => mydomain.com` where as my staging server does not share that domain name. So after removing that entry from general.config, everything is working. Thanks for your help  
  > **username_1**: Glad you got it sorted!  Would you mind adding that as an official answer in case someone runs into it?  
  
  ---
  
  ## 0 answers
  
  