- Affected version
- 2.0.0 RC1
Okay, I know this one isn't quite a bug (sorry). I understand if this must be moved to suggestions, but it's a simple change that I had requested a while back during the demo that I think could be useful.
You can get cookies from the request object like so:
However, in the response object it is only possible to set cookies. It would be great if we could get some methods to get and delete cookies there as well. I know you can delete cookies from the client by setting them to false, but I mean to delete them so they aren't sent in the response at all. For example, Symfony's HttpFoundation response object uses a ResponseHeaderBag object for headers, which has both getCookies() and removeCookie() methods.
My use case is that I want to check if a certain cookie is being sent back (late into the request life-cycle), and conditionally remove it or modify it.
It should be about as straight forward as this, I believe:
I would certainly appreciate if this could be considered.
Jeremy
You can get cookies from the request object like so:
PHP:
$cookies = \XF:app()->request()->getCookies();
However, in the response object it is only possible to set cookies. It would be great if we could get some methods to get and delete cookies there as well. I know you can delete cookies from the client by setting them to false, but I mean to delete them so they aren't sent in the response at all. For example, Symfony's HttpFoundation response object uses a ResponseHeaderBag object for headers, which has both getCookies() and removeCookie() methods.
My use case is that I want to check if a certain cookie is being sent back (late into the request life-cycle), and conditionally remove it or modify it.
It should be about as straight forward as this, I believe:
PHP:
public function removeCookie($name)
{
unset($this->cookies[$name]);
return $this;
}
public function cookies()
{
return $this->cookies;
}
I would certainly appreciate if this could be considered.
Jeremy