When I try to log in to CP as admin with correct credentials I'm getting "Invalid username or password" error and the response contains errorCode: 0 (I'm guessing CBaseUserIdentity::ERROR_NONE)

Weird part is that when I pull the same database to my local dev I can login using same credentials.

Only thing I can see in the logs is:

Tried to restore session from a cookie, but the given login name does not match the given uid. UID: bd098373-8d73-4f6c-8326-9f5a2825f5a4 and loginName: Guest.

PHP can write into /craft/storage folder. I tried clearing out craft_session table, overridePhpSessionLocation => false and removing craft/storage/runtime/, nothing helped.

I'm using PHP7.1 and MySQL 5.7.

  • Do you have anything blocking/interfering with cookies being set in your browser? Have you tried it from multiple browsers?
    – Brad Bell
    Commented Nov 9, 2017 at 15:02
  • Tried it on latest Chrome and Firefox without any add-ons. In normal and private mode. Same result. Commented Nov 9, 2017 at 15:23

1 Answer 1


Ok I've solved the issue. PHP was trying to save the sessions into a non-existing directory.

To check the current session path, I've added var_dump(session_save_path()); in Craft's /public/index.php (was set to /var/lib/php-fpm/session).

Fix was to update session.save_path setting in the php.ini to point to the right directory with correct permission.

Hope this helps someone in the future.

  • Nice. This article may be of use to you as well, in your session spelunking. In general, I've found Redis to be a nicer solution for PHP session handling: The Case of the Missing PHP Session Commented Nov 9, 2017 at 16:01
  • Thanks. Yeah, Redis is the next step, but I didn't want to introduce even more variables into the equation. Commented Nov 9, 2017 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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