'Magento cookie settings for subdomain
When I am installing Magento under a subdomain of my production domain, I cannot login to magento admin. For example, my domain name is example.com where I have installed magento and it is in production, I am ok with admin login.
However, I have a subdomain called test.example.com and I installed magento there for testing purpose. Now, if I try to login to the test site, I can't login. The username and passwords are correct. I see no error message. It just reloads the same login page. Same things happens when I try to login to my production site admin panel.
If I clear the cookies related to example.com and test.example.com and then try to login to the admin panel of example.com, I am fine. Now, when I try to login to test.example.com admin panel, the problem starts again.
Is there anybody who can help me solving this issue?
Solution 1:[1]
Finally I have solved the problem by putting the cookie domain value to www.example.com to production and test.example.com to my test site from Session Cookie management from the admin. Although this solution will not allow users to login without www i.e. example.com/admin will not work. We will have to use www.example.com/admin for successfully login to magento admin
Solution 2:[2]
I have just migrate magento code from 2.2.5 to 2.4.3-p1 to a different server and enviroment. Parent domain and Sub-domain are hosted on cloudflare. As xyz.com and test.xyz.com.
I am not able to login to frontenad backend admin portal. Even after using correct credentials.
Action already taken: update core_config_data table in db as changed cookie domain value to .test.xyz.com , test.xyz.com , NULL , blank. Nothing is working . Pls help.
Delete cookies and cache from browser and magento. For Session storage i am using AWS Elast-cache Redis.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mohaimen |
| Solution 2 | akki |

