Magento 2 can't login to admin - thumbnail

How to Solve: Magento 2 Can’t Login to Admin

by Juvia

Problem Magento 2 Can’t Login to Admin

Following the update of your Magento store to the latest version, you completed the necessary setup tasks, including meeting server requirements, implementing SSL, configuring your Website, Store, and Store View, and providing details in the store configuration.  However, you encountered a sudden that Magento 2 can’t login to admin anymore.

Despite thorough checks, there are no error messages, or console issues in Chrome/Firefox, and clearing sessions and cache did not resolve the problem. You had found answers that keep pointing back to sessions and cache settings. Then, you did follow the documentation, but it still doesn’t work.

Be glad that this article is the solution for you.

The solution to Solve Magento 2 Can’t Login to Admin

Emergency Solution

Before proceeding further, try the following steps to see if you can successfully login.

The steps provided involve accessing the database through phpMyAdmin and modifying certain values in the xxx_core_config_data:

Steo 1: Access your database using phpMyAdmin or a similar tool.

Step 2: Select the xxx_core_config_data table (you can also replace “xxx_” with your table prefix).

Step 3: Use the search function to find rows containing “cookie” in the “path” column.

Step 4: Delete the values of the following paths, if present:

web/cookie/cookie_domain
web/cookie/cookie_httponly
web/cookie/cookie_lifetime
web/cookie/cookie_path

Step 5: Refresh the Magento admin page and attempt to log in.

Now, if you still encounter the Magento 2 cannot access admin issue after following these steps, the problem may be different, and further investigation is recommended.

The Fix for Login Issue

If the Magento 2 cannot login to admin problem still cannot be resolved, perhaps you have another problem caused by domain cookies. Typically, the instructions advise setting the cookie domain as .domain.com, expecting it as a subdomain. However, the store’s base URL is registered as http://domain.com. The conflict appears here.

There are 2 ways to address this problem.

  • Solution 1: If you don’t intend to use a subdomain for cookie storage

Go to Stores -> Configuration -> Web -> Cookie Domain, and set it as domain.com without a preceding period and parentheses.

  • Solution 2: If you plan for the future that allows setting cookie storage

For the first, you should set the Cookie Domain as .domain.com with a preceding period and without the parentheses. Next, in the base URL configuration under Stores -> Configuration -> Web -> Base URL, add “www” to your domain name, like http://www.domain.com. If SSL is implemented (which is recommended), ensure the secure base URL includes “https” as part of the setup.

magento 2 can't login to admin: Magento dashboard

As a final step, don’t forget to check other Cookie Settings as follows:

  • Cookie Lifetime: 86400 (Consider leaving it blank and checking “use system value” for enhanced security.)
  • Cookie Path
  • Use HTTP Only: Yes
  • Cookie Restriction Mode: Choose according to your preference. Enabling this option prompts users on the front end for cookie storage consent.

This information is documented for future reference and to assist anyone encountering similar frustrations.

Along with this article, BSS Commerce also has another helpful articles which is Magento 2 tutorial. By reading this document, you will  be more proficient in using Magento eCommerce platform.

Conclusion

In a nut shell, BSS Commerce hope that the article has provided you with the reasons why Magento 2 can’t login to admin and the solutions for them.

We are proud to be one of the leading Magento 2 extension providers and web development services in the world. We provide more than 180+ extensions as well as other Magento website development services to help you optimize your store’s performance.

Next Reading Suggestions

© 2019 BSS Commerce owned by THANH CONG INTER ., JSC. All Rights Reserved.
Business registration certificate no. 0106064469 issued by Hanoi Department of Planning and Investment on 19 December 2019.
Legal Representative: Mr. Nguyen Quang Trung.