bug #35656 [HttpFoundation] Fixed session migration with custom cookie lifetime (Guite)
This PR was squashed before being merged into the 3.4 branch.
Discussion
----------
[HttpFoundation] Fixed session migration with custom cookie lifetime
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #28577
| License | MIT
| Doc PR |
This PR adds the fix proposed in https://github.com/symfony/symfony/issues/28577#issuecomment-578052397
Commits
-------
3e824de385
[HttpFoundation] Fixed session migration with custom cookie lifetime
This commit is contained in:
commit
78770e7f7c
@ -213,8 +213,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== $lifetime) {
|
||||
if (null !== $lifetime && $lifetime != ini_get('session.cookie_lifetime')) {
|
||||
$this->save();
|
||||
ini_set('session.cookie_lifetime', $lifetime);
|
||||
$this->start();
|
||||
}
|
||||
|
||||
if ($destroy) {
|
||||
|
@ -123,6 +123,19 @@ class NativeSessionStorageTest extends TestCase
|
||||
$this->assertEquals(11, $storage->getBag('attributes')->get('legs'));
|
||||
}
|
||||
|
||||
public function testRegenerateWithCustomLifetime()
|
||||
{
|
||||
$storage = $this->getStorage();
|
||||
$storage->start();
|
||||
$id = $storage->getId();
|
||||
$lifetime = 999999;
|
||||
$storage->getBag('attributes')->set('legs', 11);
|
||||
$storage->regenerate(false, $lifetime);
|
||||
$this->assertNotEquals($id, $storage->getId());
|
||||
$this->assertEquals(11, $storage->getBag('attributes')->get('legs'));
|
||||
$this->assertEquals($lifetime, ini_get('session.cookie_lifetime'));
|
||||
}
|
||||
|
||||
public function testSessionGlobalIsUpToDateAfterIdRegeneration()
|
||||
{
|
||||
$storage = $this->getStorage();
|
||||
|
Reference in New Issue
Block a user