Answers.Body: <p>Ok I've solved the issue. PHP was trying to save the sessions into a non-existing directory.</p>
  
  <p>To check the current session path, I've added <code>var_dump(session_save_path());</code> in Craft's <code>/public/index.php</code> (was set to <code>/var/lib/php-fpm/session</code>).</p>
  
  <p>Fix was to update <code>session.save_path</code> setting in the php.ini to point to the right directory with correct permission.</p>
  
  <p>Hope this helps someone in the future.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-09T16:01:53.737Z
Answers.Text: 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](https://nystudio107.com/blog/the-case-of-the-missing-php-session)
Answers.UserDisplayName: andrew.welch
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-09T16:03:08.300Z
Answers.Text: Thanks. Yeah, Redis is the next step, but I didn't want to introduce even more variables into the equation.
Answers.UserDisplayName: Christian P
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-09T15:58:15.953Z
Answers.LastActivityDate: 2017-11-09T17:10:44.950Z
Answers.LastEditDate: 2017-11-09T17:10:44.950Z
Answers.UserDisplayName: Christian P
Body: <p>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 <code>errorCode: 0</code> (I'm guessing CBaseUserIdentity::ERROR_NONE)</p>
  
  <p>Weird part is that when I pull the same database to my local dev I can login using same credentials. </p>
  
  <p>Only thing I can see in the logs is:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>PHP can write into /craft/storage folder. I tried clearing out craft_session table, overridePhpSessionLocation => false and removing craft/storage/runtime/, nothing helped. </p>
  
  <p>I'm using PHP7.1 and MySQL 5.7. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-09T15:02:16.927Z
Comments.Text: Do you have anything blocking/interfering with cookies being set in your browser?  Have you tried it from multiple browsers?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-09T15:23:28.297Z
Comments.Text: Tried it on latest Chrome and Firefox without any add-ons. In normal and private mode. Same result.
Comments.UserDisplayName: Christian P
Tags: <login>
Title: Invalid username or password, errorCode:0 but I'm using correct credentials
ThreadText: # Invalid username or password, errorCode:0 but I'm using correct credentials
  
  (Asked by: username_0 on 2017-11-09)
  
  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.
  
  **Tags:** login
  
  > **Comments:**
  > **username_1**: Do you have anything blocking/interfering with cookies being set in your browser?  Have you tried it from multiple browsers?  
  > **username_0**: Tried it on latest Chrome and Firefox without any add-ons. In normal and private mode. Same result.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-11-09. Score: 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.
  
  > **Comments:**
  > **username_2**: 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](https://nystudio107.com/blog/the-case-of-the-missing-php-session)  
  > **username_0**: Thanks. Yeah, Redis is the next step, but I didn't want to introduce even more variables into the equation.  
  
  ---
  
  