<p>Well, it's finally figured out by something that I never thought of before this.</p>
<p>It was based on sessions not working correctly. This was because there is a php.ini file in the root folder with this line:</p>
<pre><code># session.save_path = &quot;/var/cpanel/php/sessions/ea-php71&quot;
</code></pre>
<p>The server that the site was moved to wasn't based on cPanel, so that directory didn't exist and there were no permissions to create it. With that, sessions failed to start because nothing could be saved.</p>
<p>The fix is to set up that folder to point to the new servers local /tmp/ folder. Set that, and it all works again now!</p>

CC BY-SA 4.0
2023-03-23T19:07:39.527Z
Great job! Feel free to mark your own answer as "The Answer" to get credit for it and highlight it as a fix for the community.
cherrykoda
CC BY-SA 4.0
2023-03-23T06:31:07.743Z
2023-03-23T06:31:07.743Z
Michael
<p>It sounds like you might have an issue with a stored session. You can safely delete the <code>craft/storage/runtime/sessions</code> directory and it will remove all active sessions. Craft will automatically re-populate it with no issues.</p>
<p>Make sure not to delete the <code>craft/storage</code> folder though.</p>

CC BY-SA 4.0
2023-03-19T22:23:26.077Z
That folder doesn't exist on the site. the only folder that's close is /cache/ and I've cleared that.
Michael
CC BY-SA 4.0
2023-03-19T22:33:58.647Z
I did see that there is a database table called 'craft_sessions'. I've truncated that table and tried to log in again, and there's no difference.
Michael
CC BY-SA 4.0
2023-03-22T02:14:26.697Z
After a lot of digging, it looks like it is a session issue. BUT... there is no 'sessions' folder on the server, and the sessions table in the DB looks to be populating correctly (as in there is an entry for a session when I try to log in after truncating the table).

Is there any way to check how/what is set up for sessions?
Michael
CC BY-SA 4.0
2023-03-22T18:52:41.897Z
@Michael can you confirm what version of Craft you're on? It'll help us return the right answer for your setup. Thanks!
cherrykoda
CC BY-SA 4.0
2023-03-22T22:40:23.870Z
The version that's shown in the DB is 2.9.2.
Michael
CC BY-SA 4.0
2023-03-17T20:40:32.260Z
2023-03-17T20:40:32.260Z
cherrykoda
<p>We've moved our site to a new server, and every attempt to log in with known username/passwords comes back as the standard &quot;Invalid username or password&quot; response.</p>
<p>I've tried to follow the code as much as I can, but I'm at a standstill and can't see where the error is. The only clue that I have is on the craft.log file with this entry:</p>
<pre><code>2023/03/17 00:31:18 [warning] [application] Tried to restore session from a cookie, but the given login name does not match the given uid. UID: 758beb80-b30e-4f12-969f-e2469d491d51 and loginName: Guest.
2023/03/17 00:31:20 [warning] [application] michael tried to log in unsuccessfully.
</code></pre>
<p>I don't understand why the login name is 'Guest', as that's not a login that we are using, and I don't understand why its trying to restore a session from a cookie.</p>
<p>Is this something that anyone else has seen before, or is there ant other better ways to debug this issue to see why this is happening?</p>
<p>The password has been rest successfully for that account on the new server, and the problem still persists with the same error and log entry.</p>

CC BY-SA 4.0
2023-03-17T02:13:14.413Z
What's your phperrors and web log say? It could be related to the server, redirects, etc.
Tim Strawbridge
CC BY-SA 4.0
2023-03-17T02:43:24.803Z
There's no PHP errors. The logs that I have access to don't give any indication of anything wrong as it's just the AJAX login request that's processed, which completed correctly, just won't let me log in.
Michael
CC BY-SA 4.0
2023-03-17T02:45:28.397Z
Just to add... the login process is actually processing, so it's all working as expected that way. It is just not seeing the username and password as correct, even with the verified username and email that's in the database, and after using the password reset functions, that all worked correctly. I can see in the database that the password was updated, but the site won't allow me to log in.
Michael
CC BY-SA 4.0
2023-03-17T03:00:16.650Z
Have you looked at the http response?
Tim Strawbridge
CC BY-SA 4.0
2023-03-17T03:50:29.080Z
The HTTP response is: {"errorCode":0,"error":"Invalid username or password."}
Michael
CC BY-SA 4.0
2023-03-20T21:13:00.140Z
Are you 100% sure the Craft installation is connecting to the database you think it's connecting to?
Brad Bell
CC BY-SA 4.0
2023-03-20T23:08:23.580Z
Yes I am. The users table reflects changes made when the password is reset, and it's on a dedicated VPS - there are no other databases to connect to.
Michael
<login>
Moved site to new server and can't login
# Moved site to new server and can't login

(Asked by: username_0 on 2023-03-17)

We've moved our site to a new server, and every attempt to log in with known username/passwords comes back as the standard "Invalid username or password" response.
I've tried to follow the code as much as I can, but I'm at a standstill and can't see where the error is. The only clue that I have is on the craft.log file with this entry:
2023/03/17 00:31:18 [warning] [application] Tried to restore session from a cookie, but the given login name does not match the given uid. UID: 758beb80-b30e-4f12-969f-e2469d491d51 and loginName: Guest.
2023/03/17 00:31:20 [warning] [application] michael tried to log in unsuccessfully.

I don't understand why the login name is 'Guest', as that's not a login that we are using, and I don't understand why its trying to restore a session from a cookie.
Is this something that anyone else has seen before, or is there ant other better ways to debug this issue to see why this is happening?
The password has been rest successfully for that account on the new server, and the problem still persists with the same error and log entry.

**Tags:** login

> **Comments:**
> **username_1**: What's your phperrors and web log say? It could be related to the server, redirects, etc.  
> **username_0**: There's no PHP errors. The logs that I have access to don't give any indication of anything wrong as it's just the AJAX login request that's processed, which completed correctly, just won't let me log in.  
> **username_0**: Just to add... the login process is actually processing, so it's all working as expected that way. It is just not seeing the username and password as correct, even with the verified username and email that's in the database, and after using the password reset functions, that all worked correctly. I can see in the database that the password was updated, but the site won't allow me to log in.  
> **username_1**: Have you looked at the http response?  
> **username_0**: The HTTP response is: {"errorCode":0,"error":"Invalid username or password."}  
> **username_2**: Are you 100% sure the Craft installation is connecting to the database you think it's connecting to?  
> **username_0**: Yes I am. The users table reflects changes made when the password is reset, and it's on a dedicated VPS - there are no other databases to connect to.  

---

## 2 answers

### Answer by username_0 on 2023-03-23. Score: 3 | Accepted answer

Well, it's finally figured out by something that I never thought of before this.
It was based on sessions not working correctly. This was because there is a php.ini file in the root folder with this line:
# session.save_path = "/var/cpanel/php/sessions/ea-php71"

The server that the site was moved to wasn't based on cPanel, so that directory didn't exist and there were no permissions to create it. With that, sessions failed to start because nothing could be saved.
The fix is to set up that folder to point to the new servers local /tmp/ folder. Set that, and it all works again now!

> **Comments:**
> **username_3**: Great job! Feel free to mark your own answer as "The Answer" to get credit for it and highlight it as a fix for the community.  

---

### Answer by username_3 on 2023-03-17. Score: 1

It sounds like you might have an issue with a stored session. You can safely delete the `craft/storage/runtime/sessions` directory and it will remove all active sessions. Craft will automatically re-populate it with no issues.

Make sure not to delete the `craft/storage` folder though.

> **Comments:**
> **username_0**: That folder doesn't exist on the site. the only folder that's close is /cache/ and I've cleared that.  
> **username_0**: I did see that there is a database table called 'craft_sessions'. I've truncated that table and tried to log in again, and there's no difference.  
> **username_0**: After a lot of digging, it looks like it is a session issue. BUT... there is no 'sessions' folder on the server, and the sessions table in the DB looks to be populating correctly (as in there is an entry for a session when I try to log in after truncating the table).  Is there any way to check how/what is set up for sessions?  
> **username_3**: @username_0 can you confirm what version of Craft you're on? It'll help us return the right answer for your setup. Thanks!  
> **username_0**: The version that's shown in the DB is 2.9.2.  

---

