File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
dev/tests/integration/testsuite/Magento/Backend/Model/Auth
lib/internal/Magento/Framework/Session Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 7
7
8
8
/**
9
9
* @magentoAppArea adminhtml
10
+ * @magentoAppIsolation enabled
11
+ * @magentoDbIsolation enabled
10
12
*/
11
13
class SessionTest extends \PHPUnit_Framework_TestCase
12
14
{
@@ -34,6 +36,7 @@ protected function setUp()
34
36
$ this ->auth = $ this ->objectManager ->create (\Magento \Backend \Model \Auth::class);
35
37
$ this ->authSession = $ this ->objectManager ->create (\Magento \Backend \Model \Auth \Session::class);
36
38
$ this ->auth ->setAuthStorage ($ this ->authSession );
39
+ $ this ->auth ->logout ();
37
40
}
38
41
39
42
protected function tearDown ()
Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ public function start()
188
188
$ this ->setSessionId ($ this ->sidResolver ->getSid ($ this ));
189
189
session_start ();
190
190
$ this ->validator ->validate ($ this );
191
+ $ this ->renewCookie ();
191
192
192
193
register_shutdown_function ([$ this , 'writeClose ' ]);
193
194
@@ -198,6 +199,35 @@ public function start()
198
199
return $ this ;
199
200
}
200
201
202
+ /**
203
+ * Renew session cookie to prolong session
204
+ *
205
+ * @return $this
206
+ */
207
+ private function renewCookie ()
208
+ {
209
+ if (!$ this ->getCookieLifetime ()) {
210
+ return $ this ;
211
+ }
212
+ $ cookieValue = $ this ->cookieManager ->getCookie ($ this ->getName ());
213
+ if ($ cookieValue ) {
214
+ $ metadata = $ this ->cookieMetadataFactory ->createPublicCookieMetadata ();
215
+ $ metadata ->setPath ($ this ->sessionConfig ->getCookiePath ());
216
+ $ metadata ->setDomain ($ this ->sessionConfig ->getCookieDomain ());
217
+ $ metadata ->setDuration ($ this ->sessionConfig ->getCookieLifetime ());
218
+ $ metadata ->setSecure ($ this ->sessionConfig ->getCookieSecure ());
219
+ $ metadata ->setHttpOnly ($ this ->sessionConfig ->getCookieHttpOnly ());
220
+
221
+ $ this ->cookieManager ->setPublicCookie (
222
+ $ this ->getName (),
223
+ $ cookieValue ,
224
+ $ metadata
225
+ );
226
+ }
227
+
228
+ return $ this ;
229
+ }
230
+
201
231
/**
202
232
* Register save handler
203
233
*
You can’t perform that action at this time.
0 commit comments