8000 When getting the session's id, check if the session is not closed · symfony/symfony@5b9a727 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 5b9a727

Browse files
committed
When getting the session's id, check if the session is not closed
This introduced a regression from #9246, with an incomplete fix ; As the `started` flag on the NativeSessionStorage was not `true` anymore when saving the session, the session id was always empty when saving it, and thus when sending the `PHPSESSID` cookie
1 parent 763c8aa commit 5b9a727

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function start()
161161
*/
162162
public function getId()
163163
{
164-
if (!$this->started) {
164+
if (!$this->started && !$this->closed) {
165165
return ''; // returning empty is consistent with session_id() behaviour
166166
}
167167

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ public function testGetId()
6262
{
6363
$storage = $this->getStorage();
6464
$this->assertEquals('', $storage->getId());
65+
6566
$storage->start();
6667
$this->assertNotEquals('', $storage->getId());
68+
69+
$storage->save();
70+
$this->assertNotEquals('', $storage->getId());
6771
}
6872

6973
public function testRegenerate()

0 commit comments

Comments
 (0)
0