diff --git a/ChangeLog.md b/ChangeLog.md index bc83dc9..a6d79e1 100755 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,12 @@ Sessions for the XP Framework ChangeLog ======================================================================== +## 1.0.1 / 2019-09-13 + +* Fixed cookie transport to transmit path and domain when deleting the + cookie. See PR #9 for discussion. + (@thekid) + ## 1.0.0 / 2019-08-23 * **Heads up:** The `Sessions::in($path)` and `Sessions::insecure()` diff --git a/src/main/php/web/session/Cookies.class.php b/src/main/php/web/session/Cookies.class.php index daf0841..f43c1d1 100755 --- a/src/main/php/web/session/Cookies.class.php +++ b/src/main/php/web/session/Cookies.class.php @@ -111,6 +111,9 @@ public function attach($sessions, $response, $session) { * @return void */ public function detach($sessions, $response, $session) { - $response->cookie(new Cookie($sessions->name(), null)); + $response->cookie((new Cookie($sessions->name(), null)) + ->path($this->attributes['path']) + ->domain($this->attributes['domain']) + ); } } \ No newline at end of file diff --git a/src/test/php/web/session/unittest/SessionsTest.class.php b/src/test/php/web/session/unittest/SessionsTest.class.php index 8132d23..fa53acf 100755 --- a/src/test/php/web/session/unittest/SessionsTest.class.php +++ b/src/test/php/web/session/unittest/SessionsTest.class.php @@ -130,6 +130,32 @@ public function detach() { $this->assertEquals([$sessions->name() => ''], [$cookie->name() => $cookie->value()]); } + #[@test] + public function detach_uses_path() { + $sessions= $this->fixture()->via((new Cookies())->path('/testing')); + $response= $this->response(); + + $session= $sessions->create(); + $session->destroy(); + $session->transmit($response); + + $cookie= $response->cookies()[0]; + $this->assertEquals('/testing', $cookie->attributes()['path']); + } + + #[@test] + public function detach_uses_domain() { + $sessions= $this->fixture()->via((new Cookies())->domain('example.org')); + $response= $this->response(); + + $session= $sessions->create(); + $session->destroy(); + $session->transmit($response); + + $cookie= $response->cookies()[0]; + $this->assertEquals('example.org', $cookie->attributes()['domain']); + } + #[@test] public function valid() { $session= $this->fixture()->create();