2

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}
REQUEST_URI=/members/login
HTTP_REFERER=http://www.domain.co.uk/members/login
---

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

8
  • 1
    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. 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. 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
2

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

2

Once the same problem happened for me because of server caching and it may happen because of client-side cookie/cache. Sometimes, server caching will cache the entire form including CSRF token. So if there any option to use the minimal cache on the server, apply it/remove the server cache option itself. it may fix this problem.

Note: This only my experience. it may be right/wrong.

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.