I have just deployed an existing site to a new server. As the DNS is not pointing there yet, I have simply edited my /etc/hosts file on my Mac to point to the IP address for testing. Whilst checking through everything, it seems the site is functioning well, assets have been copied over etc. The only problem is that I am getting an error when trying to log in.

From the front end I get the message: Bad Request: The CSRF token could not be verified.

    2017/07/17 13:52:33 [error] [exception.Craft\HttpException.400] Craft\HttpException: The CSRF token could not be verified. in /home/forge/www.domain.co.uk/craft/app/services/HttpRequestService.php:1337
Stack trace:
#0 /home/forge/www.domain.co.uk/craft/app/framework/base/CComponent.php(561): Craft\HttpRequestService->validateCsrfToken(Object(CEvent))
#1 /home/forge/www.domain.co.uk/craft/app/framework/base/CApplication.php(212): CComponent->raiseEvent('onbeginrequest', Object(CEvent))
#2 /home/forge/www.domain.co.uk/craft/app/framework/base/CApplication.php(183): CApplication->onBeginRequest(Object(CEvent))
#3 /home/forge/www.domain.co.uk/craft/app/index.php(62): CApplication->run()
#4 /home/forge/www.domain.co.uk/public/index.php(19): require_once('/home/forge/www...')
#5 {main}

And from the craft admin login form, this comes up on the console after clicking Login

VM43:1 POST http://www.domain.co.uk/index.php?p=admin/actions/users/login 400 (Bad Request)

One point to note is that the original website was SSL encrypted but the new server hasn't had an SSL cert installed yet, because DNS is not pointing to it yet. However I have altered the /craft/config/general.php config file to reflect the http:// domain.

Any help would be appreciated. Running latest craft 2.6.2987

  • It sounds like an old value is cached somewhere/how. If you are unable to log into the CP Check out this thread to manually clear the db cache to see if you can log in. – Damon Jul 17 '17 at 14:23
  • I cleared the three tables craft_templatecachecriteria, craft_templatecacheelements & craft_temlpatecaches however I still get the same issue. – Adam Menczykowski Jul 17 '17 at 14:27
  • I also checked to see if any of the login form code is within {% cache %} tags but it is not. – Adam Menczykowski Jul 17 '17 at 14:28
  • Try clearing your browser's cookies. If that doesn't work, what are the domains for Craft's cookies being set to? – Brad Bell Jul 17 '17 at 16:57
  • @BradBell How do we check the domains for Craft's cookies being to sent? (apologies, front end stuff is not my strong stuff) – isral Aug 16 '17 at 12:51

I have exactly the same issue, clearing cookies worked for me

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.