From 5b9a727705c9c4086233a2c48704fdb163fe45eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baptiste=20=22Talus=22=20Clavi=C3=A9?= Date: Mon, 25 Nov 2013 17:32:50 +0100 Subject: [PATCH] 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 --- .../HttpFoundation/Session/Storage/NativeSessionStorage.php | 2 +- .../Tests/Session/Storage/NativeSessionStorageTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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()