diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index bdb8351740a73..45a45d608c042 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -161,7 +161,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 b99941aa2c080..8e32794969ced 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -62,8 +62,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()