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.

  • first post the question then in below click on Answer Your answer and add answer their. Commented Feb 20, 2017 at 11:25
  • Got it. I added the official answer at the bottom as per your request. Commented Feb 20, 2017 at 11:40

18 Answers 18


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.

  • Saved my day! Thanks! I was suspecting issues with the cookie restriction mode settings I made last time, so the problem indeed turned out to be the cookie domain value set to ".domain.com". I changed the value from the database web/cookie/cookie_domain to "domain.com" and was able to log in admin area successfully. Commented Jun 20, 2018 at 13:19
  • First though, clear your cookies. just to check they aren't in the way. Commented Apr 13, 2022 at 9:05
  • Here we are in 2023 on version 2.4.6 and this post saved me hours of agony. Thanks for posting this.
    – Jon
    Commented Jul 14, 2023 at 14:51

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%";


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

Try to log and if doesn't work then check your log file for any 3rd party conflict or error.

Thanks, sam

  • Thank you! This fixed the issue: php bin/magento config:set system/security/max_session_size_admin 2560000. In Magento 2.4.5, it seems that a value of "0" for "Max Session Size in Admin" breaks it. Commented Jul 25, 2023 at 15:30
  • Thanks very much. It works for me that to delete relevant data of %web/cookie%.
    – Zoe
    Commented Mar 1 at 14:10
  • php bin/magento config:set system/security/max_session_size_admin 2560000 saves my day Commented Apr 16 at 9:53

I experienced this after setting up a new project done previously by the other devs. On my end, this is how I fixed this.

In core_config_data table, I searched for the path web/cookie/cookie_domain. And then found out that the domain is not the same with the current project's domain. So I just changed it to be same as the current project domain. And then after that, the admin login works.

  • 1
    Thanks. this fixed my issue . Making it null also worked for me. Commented Jun 4, 2021 at 17:06

Quick Fix:

Add or Update Web Url entries to https:// secure urls for below configuration entries in database

In Table > core_config_data set below value for your store:

  1. web/unsecure/base_url => 'https://yoursiteurl.com/'

  2. web/secure/base_url => 'https://yoursiteurl.com/'

Also, check cookie settings for website, if in doubt try to remove all cookie settings from core_config_data table and login to admin. Afterwards, add proper cookie settings from admin configurations.


In my case I forgot to set config value ture for use secur admin url.

I read in your statement, you mentioned that SSL is installed, Please check if admin url is being opened as secure ( using https:// ). If your website is running on HTTPS then admin url should be set to use secure url. you can set config value for admin url

php bin/magento config:set web/secure/use_in_adminhtml 1
  • awesome solution Commented Nov 16, 2021 at 17:55
  • This answer solved my problem in M2.4.3..Thank you..Upvoted Commented Nov 20, 2022 at 20:32

There is two to there cases for the issue:

  • Open the core_config_data table

  • Find the web/cookie/cookie_domain and update you domin name

  • If Your domain is secure then add the https:// in you domin otherwise you add the http:// only

  • web/unsecure/base_url => https://yoursiteurl.com/

  • web/secure/base_url => https://yoursiteurl.com/

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

Clear your Browser cookies and cache.


Clearing cookies fixed it for me thanks. http://www.editthiscookie.com/

  • 1
    Watch out. They could steal your cookie.
    – Black
    Commented Feb 17, 2022 at 11:49

may deleting var, generated directory can solve the issue.

  • deleting only the generated folder helped
    – Oboroten
    Commented Jun 14 at 16:54

Soon after the Magento Installation, if you are running into the below issues: a. The admin is not able to login after successful installation b. Magento2: Error 404 not found at the magento2 admin login page after successful installation. c. The links on the admin page not working.

Perform the below steps

a. Add the extra code to the **Validator.php** file which you will generally find from below given system path.
     Path: C:\xampp\htdocs\<Your Magento Folder>\vendor\magento\framework\View\Element\Template\File

     * Checks whether path related to the directory
     * @param string $path
     * @param string|array $directories
     * @return bool
    protected function isPathInDirectories($path, $directories)
        if (!is_array($directories)) {
            $directories = (array)$directories;
        $realPath = $this->fileDriver->getRealPath($path);
        **$realPath = str_replace('\\', '/', $realPath);   <<<====== Extra Code**
        foreach ($directories as $directory) {
            if (0 === strpos($realPath, $directory)) {
                return true;
        return false;

b. This will regenerate all the files
      # php -d memory_limit=1G bin/magento setup:static-content:deploy -f

c. This will flush all the cache from the 2 directories var and generated
      Delete files form the folowing folders
        1. var 
        2. generated

This should fix the issue


Emergency Fix In local

Hello, If you are working in the local system and need to fix this issue urgently, So please follow the below steps.

I know this is not a proper solution but this is working fine in the local my system.

Open below file


Comment 221 and 231 lines

     * Process of configuring of current auth storage when login was performed
     * @return \Magento\Backend\Model\Auth\Session
    public function processLogin()
//        if ($this->getUser()) {

            if ($this->_backendUrl->useSecretKey()) {

//        }
        return $this;

Please run below commands and check it's work for me.

composer update
php -f bin/magento setup:upgrade
php -f bin/magento setup:static-content:deploy en_US -f
php -f bin/magento cache:flush

I had the same problem and all the solutions offered here did not work for me. But I did found the solution for my situation!

You should not forget the www. in front of your domain, otherwise cookies can't process your login correctly.

Solution example:

https://yourdomain.com/admin is wrong https://www.yourdomain.com/admin is correct


enter image description here

This answer was not mentioned and worked for me so here goes set this in db and run the above commands if required

bin/magento config:set admin/usage/enabled 1

you can see here


I had a similar problem. Everytime I tried to login, the form just reloaded without error.

It was because of a bad subdomain name. I choosed ee.test.example.com, which was causing the issue, because it indicates that it is a subdomain from a subdomain ee -> test -> example.com instead of ee-test -> example.com

I changed the name to ee-test.example.com and changed all occurenced in the database in the table core_config_data

SELECT * FROM `core_config_data` WHERE value LIKE "%ee.test.example.com%"

Try loggin in from a different browser or clean the cookies on specific browser for the specific URL

Worked for me.


Changing "http://" to "https://" worked for me.


Suppose all of the above solutions are not worked. Disable the Magento_ReCaptchaFrontendUi module and run the setup upgrade.

I have tried all the above solutions and they did not work. But disabling the Magento_ReCaptchaFrontendUi module worked for me.


Add extension=sodium to php.ini

If already added, make sure it is not commented if so uncomment it

Restart Server

Fixed, and here you go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.