Login issues are commonly encountered by frequent users of Magento. This is a widely discussed issue among Magento programmers in India. Experts have come up with multiple solutions befitting the reason for login failure.
The first solution is to change the cookie domain. This will prove to be effective when the login failure is resulted due to a mismatch between the cookie domain and server domain. You can change the cookie domain via the Configuration Admin Menu. The order of commands is as follows.
System > Configuration > General > Web
The next set of solutions will be effective in the case where multiple subdomains may be used in addition to cookies being incorrectly configured.
There are three possible solutions if this case arises. The first one being the same as that mentioned above, which is to change the cookie domain. After that give it a check. If the main domain and subdomains are hosted on the same server, check if Cookie Domain is example.com or .example.com. If not, set it to .example.com.
If your main domain and subdomains are not hosted on the same server, check if the Cookie Domain is www.example.com, after changing the cookie domain. If it isn’t, then set it to .www.example.com.
The second possible solution, in this case, involves changing the cookie domain of your php.ini file to match that in the Magento configuration, that is, if they are not the same in the first place. The third option is to change the adminhtml cookie name for subdomains. This involves a series of steps and is generally not advised by experts. This should ideally be your last resort.
The same changes, as mentioned above, can be made effective by running a few SQL queries.
The third reason behind login failure may be the creation of multiple front-end cookies. This has been known to cause login troubles in many cases. The solution in this case typically involves changing the cookie domain to .example.com for both domain and subdomain configurations. That aside, you can also try adding a cookie domain that matches the Magento configuration to your php.ini file.
If login failure is prompted by a failure to create a session data file by your did, then following a couple of steps can help you log in. The first step includes granting ownership to the folder in which sessions are saved. This is effective if the web server is nginx and web server user is www-data. In the case of vagrant, you will have to change the file session path. The third solution is much easier. The first thing needed to be executed is deleting the old sessions in the var/sessions folder. Upon doing so, check if it is indeed the cause for the trouble before you cheer.
Apart from the listed solutions, you can also try switching the session provider, if possible. Try your luck again after clearing the car/cache folder. Now, there is also a solution exclusively for the PHP7 users which is to change the Magento core read function by typecasting. Magento programmers in India have just a word of advice, do what you have got to do, so long as the job gets done.