Cakephp: Remove cookie from Response object

Created on 1 Aug 2017  路  3Comments  路  Source: cakephp/cakephp

This is a (multiple allowed):

  • [ ] bug
  • [x] enhancement
  • [ ] feature-discussion (RFC)

  • CakePHP Version: 3.5.0-RC1

What you did

I wanted to delete a cookie using the new CookieCollection.

What happened

$cookies = $this->request->getCookieCollection();
if ($cookies->has('remember_me')) {
    $cookies = $cookies->remove('remember_me');
}
$this->response = $this->response->withCookieCollection($cookies);

Although the method exists in the ServerRequest object, the withCookieCollection() method doesn't seem to exist in the Response object yet.

What you expected to happen

The response with the modified cookie collection

enhancement http

Most helpful comment

It might be easier to use if the method was $response->withoutCookie('remember_me');

All 3 comments

It might be easier to use if the method was $response->withoutCookie('remember_me');

Indeed pretty straight forward.

Thanks for taking care of this @jorisvaesen 馃檪
Closing as we have a PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lorenzo picture lorenzo  路  4Comments

nrother picture nrother  路  3Comments

inoas picture inoas  路  4Comments

ndm2 picture ndm2  路  3Comments

cleptric picture cleptric  路  3Comments