-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong cookies set for store views with multidomain #8509
Comments
Hello, @Noewt! I have same problem. Please write your steps for host nginx config. And setting in admin panel. You have found a solution? |
Hello, Did you try to set correct Cookie Domain for each stores at Stores->Configuration->General->Web->Default Cookie Settings. Set store.de for de_de storeview and so on |
I'm using this in the nginx config:
So when there is no cookie set, it loads the default language set in the config. If there is a cookie set, it should 'override' the nginx config and redirect to the storeview set in the cookie. These are the admin settings for each storeview:
|
The same problem seems to be happening in this thread #3676 |
Any decision on this issue? |
I think I have the same Issue. The Problem I face with has the following behavior: There is a condition in The following Code contains a condition which checks if the current store is equal to the default. If so, the cookie of the store will be deleted. The problem is, that the cookie of the default store is getting deleted and the referer-store stil contains the cookie. That seems to be wrong in my opinion. May someone can check it as well.
|
Hi @Noewt , i try to reproduce your bug. after configuring web views, I see on cookies and they is correct. |
Hi, @k7triton! |
Can confirm that the cookie is created in \Magento\Store\Controller\Store\SwitchAction for the wrong domain. The
On HTTPS, asset loading fails because of CORS policy. The expected behavior when switching store views is that the |
Hi, @Noewt. |
Hi, we are getting this error on a EE 2.1.7. Thanks! |
@danielozano, we ran into the same problem last week, we were able to fix it by applying MAGETWO-64885 on top of Magento CE 2.1.7, but then ran into a new issue, which I started documenting here: 508f1ef#commitcomment-23479499 We worked around this new issue using this extra change for the diff --git a/Model/Store.php b/Model/Store.php
index 7aa723ab123..e6cad7efb12 100644
--- a/Model/Store.php
+++ b/Model/Store.php
@@ -1130,7 +1130,7 @@ class Store extends AbstractExtensibleModel implements
public function getCurrentUrl($fromStore = true)
{
$sidQueryParam = $this->_sidResolver->getSessionIdQueryParam($this->_getSession());
- $requestString = $this->_url->escape(ltrim($this->_request->getRequestString(), '/'));
+ $requestString = $this->_url->escape(ltrim($this->_request->getOriginalPathInfo(), '/'));
$storeUrl = $this->getUrl('', ['_secure' => $this->_storeManager->getStore()->isCurrentlySecure()]); This extra workaround is only necessary for Magento 2.1.x, it works fine on the 2.2.0-develop branch without this workaround. Be aware, we still have to test this workaround properly, so no promises this won't break anything else. |
Hi @hostep thanks alot for your fast response! We've already applied it and if we have issues (something else breaks), will come with feedback! |
@danielozano, I didn't work on a work around but the fastest solution might be a plugin to check the cookies while you are switching a store. |
@Noewt, thank you for your report. |
This merge created a new problem with the store switcher #11211 |
We need a stable store/language switcher in Magento 2.1.9 and had same problem as described by Noewt. It seems getTargetStorePostData() in .../switch/languages.phtml is the source of the problem. Since it looks like patches available still will need some good and thorough testing, we went for following temporary workaround in .../switch/languages.phtml
This requires setting individual Cookie Domains for each store. If there is anything wrong with this temporary workaround, pls let us know (we are no Magento experts). Thanks. |
Preconditions (*)A vanilla installation of Magento 2.4.6-p1 with default settings.
Stores and Web Site Configuration: Web Site information:
Store information:
Steps to reproduce (*)Add second Store View and change the values of the main Store View for clarity English Store View (default) information:
German Store View information:
For the German store, you need to create a subdirectory in the pub, so that it can be accessed at /de/ and assign a proper URL.
+$params = $_SERVER;
+$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'de';
+$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
+$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
-$bootstrap = Bootstrap::create(BP, $_SERVER);
# PHP entry point for main application
+location ~ (index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
-location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ { For Static and Media View Files, you will need to globally change the URL to something like this: https//domain.com/static/(media/) so that the styles would be available in /de/ as well.
Specify a URL for the German store with the prefix /de/.
Change the main Store View for Store to German. (make it default)
Going to the site...
Expected result (*)There is no "store" cookie for the primary Store View.
And when switching from another Store View (en) when the "store" cookie is already set, it checks to match the target Store View with the default Store View ID.
But when try to delete the store cookie in $cookieMetadata set the path /de, but existing "store" cookie has path /. magento2/app/code/Magento/Store/Model/StoreCookieManager.php Lines 72 to 78 in 35e8e43
getStorePath() returns /de, but the "store" cookie has a path / - perhaps because of this the "store" en cookie is not deleted and the site always stays on Store View (en) magento2/app/code/Magento/Store/Model/Store.php Lines 1373 to 1378 in 35e8e43
Actual result (*)
|
Preconditions
Magento 2.1.4 CE
PHP Version 7.0.14-2a
Porto Theme 2.4.5
NGinx 1.9.11
Steps to reproduce
storeview - code - base url
GB - English - en_gb - www.store.com (default)
GB - German - de_gb - www.store.com
DE - German - de_de - www.store.de
DE - English - en_de - www.store.de
Expected result
Actual result
Both cookie-values don't match their domain.
If you now visit www.store.de, the store cookie gets called and it tries to load the en_gb storeview. This storeview has www.store.com set as base url, so it redirects to there. There's a store cookie set on that domain also, which tries to load the de_de storeview. You'll end up with a loop resulting in ERR_TOO_MANY_REDIRECTS.
The text was updated successfully, but these errors were encountered: