Skip to content

Commit 05a843b

Browse files
committed
MAGETWO-65236: Expiration date of PHPSESSID cookie is not updated
1 parent e9d894f commit 05a843b

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/internal/Magento/Framework/Session/SessionManager.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Framework\Session;
99

1010
use Magento\Framework\Session\Config\ConfigInterface;
11+
use Magento\Framework\Stdlib\Cookie\CookieMetadata;
1112

1213
/**
1314
* Session Manager
@@ -188,6 +189,7 @@ public function start()
188189
$this->setSessionId($this->sidResolver->getSid($this));
189190
session_start();
190191
$this->validator->validate($this);
192+
$this->renewCookie();
191193

192194
register_shutdown_function([$this, 'writeClose']);
193195

@@ -198,6 +200,32 @@ public function start()
198200
return $this;
199201
}
200202

203+
/**
204+
* Renew session cookie to prolong session
205+
*
206+
* @return $this
207+
*/
208+
private function renewCookie()
209+
{
210+
if (!$this->getCookieLifetime()) {
211+
return $this;
212+
}
213+
$this->cookieManager->setPublicCookie(
214+
$this->getName(),
215+
$this->getSessionId(),
216+
$this->cookieMetadataFactory->createPublicCookieMetadata(
217+
[
218+
CookieMetadata::KEY_DURATION => $this->getCookieLifetime(),
219+
CookieMetadata::KEY_DOMAIN => $this->sessionConfig->getCookieDomain(),
220+
CookieMetadata::KEY_PATH => $this->sessionConfig->getCookiePath(),
221+
CookieMetadata::KEY_SECURE => $this->sessionConfig->getCookieSecure(),
222+
CookieMetadata::KEY_HTTP_ONLY => $this->sessionConfig->getCookieHttpOnly()
223+
]
224+
)
225+
);
226+
return $this;
227+
}
228+
201229
/**
202230
* Register save handler
203231
*

lib/internal/Magento/Framework/Session/Test/Unit/SessionManagerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase
5252

5353
protected function setUp()
5454
{
55-
$this->markTestSkipped('To be fixed in MAGETWO-34751');
5655
global $mockPHPFunctions;
5756
require_once __DIR__ . '/_files/mock_ini_set.php';
5857
require_once __DIR__ . '/_files/mock_session_regenerate_id.php';

0 commit comments

Comments
 (0)