diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index e9d2e176dd47d..07c969ce7a159 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -163,7 +163,7 @@ public function start() */ public function getId() { - if (!$this->started) { + if (!$this->started && !$this->closed) { return ''; // returning empty is consistent with session_id() behaviour } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index a9d93122412f9..691ee1459347a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -85,8 +85,12 @@ public function testGetId() { $storage = $this->getStorage(); $this->assertEquals('', $storage->getId()); + $storage->start(); $this->assertNotEquals('', $storage->getId()); + + $storage->save(); + $this->assertNotEquals('', $storage->getId()); } public function testRegenerate()