@@ -123,15 +123,20 @@ public function authPreDispatch($event)
123123 /** @var \Magento\Framework\App\State $adminAppState */
124124 $ adminAppState = $ objectManager ->get ('Magento\Framework\App\State ' );
125125 $ adminAppState ->setAreaCode (\Magento \Framework \App \Area::AREA_ADMIN );
126- $ objectManager ->create (
127- 'Magento\Backend\Model\Auth\Session ' ,
126+ /** @var \Magento\Backend\Model\Session\AdminConfig $sessionConfig */
127+ $ sessionConfig = $ objectManager ->get (\Magento \Backend \Model \Session \AdminConfig::class);
128+ $ cookiePath = $ this ->getSetupCookiePath ($ objectManager );
129+ $ sessionConfig ->setCookiePath ($ cookiePath );
130+ /** @var \Magento\Backend\Model\Auth\Session $adminSession */
131+ $ adminSession = $ objectManager ->create (
132+ \Magento \Backend \Model \Auth \Session::class,
128133 [
129- 'sessionConfig ' => $ objectManager -> get ( ' Magento\Backend\Model\Session\AdminConfig ' ) ,
134+ 'sessionConfig ' => $ sessionConfig ,
130135 'appState ' => $ adminAppState
131136 ]
132137 );
133-
134- if (! $ objectManager -> get ( ' Magento\Backend\Model\Auth ' )-> isLoggedIn ()) {
138+ if (! $ objectManager -> get (\ Magento \ Backend \ Model \Auth::class)-> isLoggedIn ()) {
139+ $ adminSession -> destroy ();
135140 $ response = $ event ->getResponse ();
136141 $ baseUrl = Http::getDistroBaseUrlPath ($ _SERVER );
137142 $ response ->getHeaders ()->addHeaderLine ('Location ' , $ baseUrl . 'index.php/session/unlogin ' );
@@ -144,6 +149,25 @@ public function authPreDispatch($event)
144149 return false ;
145150 }
146151
152+ /**
153+ * Get cookie path
154+ *
155+ * @param \Magento\Framework\ObjectManagerInterface $objectManager
156+ * @return string
157+ */
158+ private function getSetupCookiePath (\Magento \Framework \ObjectManagerInterface $ objectManager )
159+ {
160+ /** @var \Magento\Backend\App\BackendAppList $backendAppList */
161+ $ backendAppList = $ objectManager ->get (\Magento \Backend \App \BackendAppList::class);
162+ $ backendApp = $ backendAppList ->getBackendApp ('setup ' );
163+ /** @var \Magento\Backend\Model\UrlFactory $backendUrlFactory */
164+ $ backendUrlFactory = $ objectManager ->get (\Magento \Backend \Model \UrlFactory::class);
165+ $ baseUrl = parse_url ($ backendUrlFactory ->create ()->getBaseUrl (), PHP_URL_PATH );
166+ $ baseUrl = \Magento \Framework \App \Request \Http::getUrlNoScript ($ baseUrl );
167+ $ cookiePath = $ baseUrl . $ backendApp ->getCookiePath ();
168+ return $ cookiePath ;
169+ }
170+
147171 /**
148172 * {@inheritdoc}
149173 */
0 commit comments