Web Development Jaipur | 9887515598

9:00 to 6:30

info@atssoftwares.com

SwarnPath , Mansarover Jaipur-302020

9887515598

Call Now

Posted On November 7, 2024

Unable to login to a …

admin 0 comments
Ats Softwares Web Development >> Magento , Magento 2 >> Unable to login to a …

This will be a self-answer to a problem that is pretty old but recurring. I remember struggling on this back in the days when I was setting up Magento 1.9 and it occurred again this time around on Magento 2.1.4. I totally forgot about how I fixed it back then, so this time around I’m documenting my answer here in case someone needs it too.

Problem Statement
Basically, you were setting up your Magento 2.1 store, fulfilled all the server requirements, added SSL, setup your Website, Store and Store View and filled up the store configuration only to realise that suddenly you can’t login to the admin panel anymore. There are no errors, nothing in the browser console, neither any problem with the browser Chrome / Firefox. You clear the sessions and cache to no avail too. You found answers that keep pointing back to sessions and cache settings, but you did follow the documentation, and it still doesn’t work.

Emergency Fix
Whether or not this solution works, please try these steps first. You WILL be able to login which means you are on the right page. If you still could not login, your issue is most likely different than the one I’m posting, please proceed at your own risk.

Go to your database. If you have phpMyAdmin, do the following:
Click on your xxx_core_config_data table (xxx_ is the additional table prefix that you might have set during installation)
Once the table is selected, hit the “search” tab on the right side
In the search menu, under “path”, select the dropdown to (LIKE %…%) and insert “cookie” in the field next to it. This will search for all table rows that contain “cookie” in their path value.
Delete the VALUE of the following (if you do not see some of them, just ignore. It might not have been setup yet, so you can omit it):
web/cookie/cookie_domain
web/cookie/cookie_httponly
web/cookie/cookie_lifetime
web/cookie/cookie_path
That’s it. Now, refresh your admin page and try logging in. It should work. If it does, now let’s get to the crux of the problem.

The Issue
Most of the time, following the guide asks us to store the cookie domain as .domain.com which is expecting a sub-domain, but the store name is stored as http://domain.com as it’s base URL.

The Fix
There are two ways to fix this problem.

If you are not going to be using a subdomain for cookie storage, you can save the cookie domain settings in Stores -> Configuration -> Web -> Cookie Domain as (domain.com) without a preceding period and parentheses.

If you plan to make your store future-ready and allow subdomain cookie storage, you should set the Cookie Domain as (.domain.com) with a preceding period and without the parentheses. However, in your base URL under Stores -> Configuration -> Web -> Base URL, add www to your domain name such as http://www.domain.com and https in the secure base URL if you are using SSL (that you should).

Additionally, other Cookie Settings are as such: Cookie Lifetime – 86400 (From my understanding, you don’t need this and can leave it blank and check “use system value” because now Magento retains the session for security reasons). Cookie Path – / Use HTTP Only – Yes Cookie Restriction Mode – Up to you. If you enable this, it will show the message on the front end asking the user’s consent to store cookies.

Note: Once again, this one is for my own future reference purposes and for anyone who might stumble into this frustration just like I did.

Well, there could be a number of reasons and it’s not just like a cookie issue cause it really depends on the version you’re running on.

Here are the steps

Make sure that you will take a backup of the core config data table

#step1. Check for cookie stuff. if you would any value for the following query then just delete via config id one by one.

select *from core_config_data where path like “%web/cookie%”;

web/cookie/cookie_domain
web/cookie/cookie_httponly
web/cookie/cookie_lifetime
web/cookie/cookie_path
php -f bin/magento setup:upgrade

php -f bin/magento setup:static-content:deploy en_US -f

php -f bin/magento cache:flush

Try to log and if doesn’t work then go for #step2.

#step2. php bin/magento config:set system/security/max_session_size_admin 2560000

php -f bin/magento cache:flush

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Post Image

Why Your Business Ne …

Why Your Business Needs a Magento 2 Development Agency Running an e-commerce business today means…

Top Magento Developm …

Magento Development Company in Jaipur In today’s digital-first marketplace, having a robust eCommerce presence is…