@@ -123,16 +123,20 @@ public function authPreDispatch($event)
123
123
/** @var \Magento\Framework\App\State $adminAppState */
124
124
$ adminAppState = $ objectManager ->get ('Magento\Framework\App\State ' );
125
125
$ adminAppState ->setAreaCode (\Magento \Framework \App \Area::AREA_ADMIN );
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 );
126
130
/** @var \Magento\Backend\Model\Auth\Session $adminSession */
127
131
$ adminSession = $ objectManager ->create (
128
132
\Magento \Backend \Model \Auth \Session::class,
129
133
[
130
- 'sessionConfig ' => $ objectManager -> get (\ Magento \ Backend \ Model \ Session \AdminConfig::class) ,
134
+ 'sessionConfig ' => $ sessionConfig ,
131
135
'appState ' => $ adminAppState
132
136
]
133
137
);
134
138
if (!$ objectManager ->get (\Magento \Backend \Model \Auth::class)->isLoggedIn ()) {
135
- $ adminSession ->expireSessionCookie ();
139
+ $ adminSession ->destroy ();
136
140
$ response = $ event ->getResponse ();
137
141
$ response ->getHeaders ()->addHeaderLine ('Location ' , 'index.php/session/unlogin ' );
138
142
$ response ->setStatusCode (302 );
@@ -145,6 +149,25 @@ public function authPreDispatch($event)
145
149
return false ;
146
150
}
147
151
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
+
148
171
/**
149
172
* {@inheritdoc}
150
173
*/
0 commit comments