2929use Shopware \Models \Shop \Shop ;
3030use Shopware \Models \Shop \Template ;
3131use Symfony \Component \HttpFoundation \Cookie ;
32+ use Symfony \Component \HttpFoundation \Response ;
3233
3334class Shopware_Plugins_Core_Router_Bootstrap extends Shopware_Components_Plugin_Bootstrap
3435{
@@ -53,14 +54,15 @@ public function install()
5354 public function onRouteStartup (Enlight_Controller_EventArgs $ args )
5455 {
5556 $ request = $ args ->getRequest ();
57+ $ response = $ args ->getResponse ();
5658
5759 if (str_starts_with ($ request ->getPathInfo (), '/backend ' )
5860 || str_starts_with ($ request ->getPathInfo (), '/api/ ' )
5961 ) {
6062 return ;
6163 }
6264
63- $ shop = $ this ->getShopByRequest ($ request );
65+ $ shop = $ this ->getShopByRequest ($ request, $ response );
6466
6567 if (!$ shop ->getHost ()) {
6668 $ shop ->setHost ($ request ->getHttpHost ());
@@ -306,7 +308,7 @@ protected function upgradeShop($request, $response)
306308 *
307309 * @return Shop
308310 */
309- protected function getShopByRequest (Request $ request )
311+ protected function getShopByRequest (Request $ request, Response $ response )
310312 {
311313 $ repository = $ this ->get (ModelManager::class)->getRepository (Shop::class);
312314
@@ -317,6 +319,7 @@ protected function getShopByRequest(Request $request)
317319
318320 if ($ shop === null && $ request ->getCookie ('shop ' ) !== null ) {
319321 $ shop = $ repository ->getActiveById ($ request ->getCookie ('shop ' ));
322+ $ response ->headers ->clearCookie ('shop ' );
320323 }
321324
322325 if ($ shop && $ request ->getCookie ('shop ' ) !== null && $ request ->getPost ('__shop ' ) === null ) {
0 commit comments